问题
I am beginner of learning C# selenium using visual studio 2015. I want to test a random website using edge browser. With the use of NuGet, I have installed selenium support (latest version)v3.141.0, selenium webdriver (latest version)v3.141.0 and selenium microsoft webdriver (latest version)v17.17134.0. However, the OS version on my laptop (latest window 10) is 18362 which is not available to download on official webdriver website.
The following code works well in chrome, IE, and firefox, but if I run the script below, I could successfully open the edge browser, but it does not proceed any more steps accordingly (just a edge browser displaying blank page). The error I get is as followed: OpenQA.Selenium.WebDriverException: "A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:54095/session. The status of the exception was ReceiveFailure, and the message was: the underlying connection was closed. An unexpected ...."
I searched through the entire internet but still could not find out any relevant resources teaching how to configure edge webdriver in my current situation. Can someone point out mistakes I made and advise what should be done to solve this issue?
[TestMethod]
public void TestInEdge()
{
// Default option, MicrosoftWebDriver.exe must be in PATH
IWebDriver driver = new EdgeDriver();
driver.Navigate().GoToUrl("http://testwisely.com/demo");
System.Threading.Thread.Sleep(1000);
driver.Quit();
}
回答1:
Microsoft WebDriver for Microsoft Edge (EdgeHTML) versions 18 and 19 is a Windows Feature on Demand which ensures that it’s always up to date automatically and enables some new ways to get Microsoft WebDriver.
To get started you will have to enable Developer Mode:
Go to Settings > Update and Security > For Developer and then select “Developer mode”.
To install run the following in an elevated command prompt:
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Reference:
Microsoft WebDriver
Then after again try to run your code with Edge browser.
来源:https://stackoverflow.com/questions/59234658/c-sharp-visual-studio-selenium-for-edge-os-version18362