(C#)Selenium如何操作新版Edge(Chromium)

Edge Driver调用代码:

driver = new EdgeDriver();
执行出错:

OpenQA.Selenium.DriverServiceNotFoundException : The MicrosoftWebDriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://go.microsoft.com/fwlink/?LinkId=619687.

原因:新版Edge浏览器对应是msedgedriver.exe,但当前版本的selenium接口默认调用MicrosoftWebDriver.exe. 

※浏览器所需的webDriver都可以通过NuGet进行下载。

(C#)Selenium如何操作新版Edge(Chromium)

 代码做如下修改即可解决这一问题:

EdgeDriverService service = EdgeDriverService.CreateDefaultService(@".\", "msedgedriver.exe");
EdgeOptions option = new EdgeOptions();
driver = new EdgeDriver(service, option);

上一篇:[算法题]洛谷 P3366 【模板】最小生成树


下一篇:edge阅读器插件开发之目标