问题
I have a problem with using Selenium with Edge. I use .NET Core 3.0.
This is my simple test:
[Fact]
public void EdgeDriverTest1() {
using (IWebDriver driver = new EdgeDriver()) {
driver.Navigate().GoToUrl("http://www.google.com");
IWebElement element = driver.FindElement(By.Name("q"));
element.SendKeys("Hello, Selenium WebDriver!");
element.Submit();
}
}
When I run it Edge window will be opened and I get the error:
OpenQA.Selenium.WebDriverException
: A exception with anull
response was thrown sending an HTTP request to the remote WebDriver server for URLhttp://localhost:60127/session
. The status of the exception wasUnknownError
, and the message was: An error occurred while sending the request
Nuget packages:
How can I fix it?
回答1:
Your code is right and this error occurs mainly because the Microsoft WebDriver version you're using doesn't match the Edge version you're using.
If you're using Edge version prior to 18, you can download the appropriate webdriver for your installed version of Microsoft Edge in this link. If your Microsoft Edge version is 18 or higher, you can install the appropriate webdriver version according to the ways in this article.
来源:https://stackoverflow.com/questions/56920240/selenium-with-edge-a-exception-with-a-null-response