0

我正在尝试使用 Java Selenium 启动 Edge 浏览器:

if(browser.equals("edge")) {
System.setProperty("webdriver.edge.driver", driverPath+"\\MicrosoftWebDriver\\MicrosoftWebDriver.exe");
driver = new EdgeDriver();
}

但我有这个例外:无法开始新会话。可能的原因是远程服务器地址无效或浏览器启动失败。

[11:25:55.747] - Listening on http://localhost:25602/ 

[Ljava.lang.StackTraceElement;@4d98e41b
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: 'EB00477', ip: '192.168.6.214', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.1'
Driver info: driver.version: EdgeDriver
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc'
System info: host: 'EB00477', ip: '192.168.6.214', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '14.0.1'
Driver info: driver.version: EdgeDriver

我的 Edge 版本是:Microsoft Edge 44.18362.449.0Microsoft EdgeHTML 18.18363

在此处输入图像描述

我尝试同时使用MicrosoftWebDriver.exemsedgedriver.exe文件,它们不起作用。我怎样才能让它工作?

4

1 回答 1

0

看起来代码没问题,而 WebDriver 和 Edge 版本不匹配。我从https://www.microsoft.com/it-it/edge安装了 Edge,然后我去了https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/并下载了正确的驱动程序版本。我必须使用msedgedriver.exe

我的代码是:

if(browser.equals("edge")) {
System.setProperty("webdriver.edge.driver", driverPath+"\\MicrosoftWebDriver\\msedgedriver.exe");
driver = new EdgeDriver();
}
于 2020-08-07T10:31:53.663 回答