我在 C# 中使用 Selenium 和 Edge 驱动程序,但是当我运行代码时,我收到以下错误。使用 OpenQA.Selenium;使用 OpenQA.Selenium.Edge;
class HomePageTests
{
static void Main(string[] args)
{
{
{
IWebDriver AzimaHome = new EdgeDriver();
AzimaHome.Navigate().GoToUrl("http:www.msn.com");
IList<IWebElement> terms = AzimaHome.FindElements(By.TagName("a"));
terms.First(element => element.Text == "").Click();
}
}
}
}
抛出异常:
OpenQA SeleniumWebDriverException' in WebDriver.dll
An unhandled exception of type SeleniumWebDriverException' occurred in WebDriverdll
A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:52586/session. The status of the exception was Receive Failure, and the message was: The underlying connection was closed: An unexpected error occurred on a receive.
顺便说一句,这是在 Visual Studio 2019 中:
_05.NoSuchElementException.exe' (CLR v4.0.30319: _05.NoSuchElementException.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Private Assemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[17312] _05.NoSuchElementException.exe' has exited with code -1 (0xffffffff).
有人可以帮忙吗?