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进行下载。
代码做如下修改即可解决这一问题:
EdgeDriverService service = EdgeDriverService.CreateDefaultService(@".\", "msedgedriver.exe"); EdgeOptions option = new EdgeOptions(); driver = new EdgeDriver(service, option);