C# visual studio selenium for edge OS version18362

C# visual studio selenium for edge OS version18362

我是使用 visual studio 2015 学习 C# selenium 的初学者。 我想使用边缘浏览器测试一个随机网站。使用NuGet,我安装了selenium support(最新版)v3.141.0、selenium webdriver(最新版)v3.141.0和selenium microsoft webdriver(最新版)v17.17134.0。但是,我的笔记本电脑上的 OS 版本(最新的 window 10)是 18362,无法在官方 webdriver 网站上下载。

下面的代码在chrome、IE、firefox中运行良好,但是如果我运行下面的脚本,我可以成功打开edge浏览器,但是它没有进行更多的步骤相应地(只是一个显示空白页面的边缘浏览器)。 我得到的错误如下: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 ...."

我找遍了整个互联网,但仍然没有找到任何相关资源教如何在我目前的情况下配置 edge webdriver。有人可以指出我犯的错误并建议应该如何解决这个问题吗?

[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();
}

适用于 Microsoft Edge (EdgeHTML) 版本 18 和 19 的 Microsoft WebDriver 是一项 Windows 按需功能,可确保它始终自动保持最新状态并启用一些获取 Microsoft WebDriver 的新方法。

要开始,您必须启用开发者模式:

Go to Settings > Update and Security > For Developer and then select “Developer mode”.

要在提升的命令提示符下安装运行以下内容:

DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

参考:

Microsoft WebDriver

然后再次尝试 运行 您的代码与 Edge 浏览器。