gpt4 book ai didi

java - Selenium webdriver 启动边缘浏览器

转载 作者:行者123 更新时间:2023-12-02 04:05:45 29 4
gpt4 key购买 nike

我的 Edge 浏览器有问题,下面是我的代码。浏览器打开,但控制权永远不会转到浏览器,而是执行停止并显示错误

service = new EdgeDriverService.Builder()
.usingDriverExecutable(new File("C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe"))
.usingAnyFreePort()
.build();
service.start();
driver = new EdgeDriver(service, DesiredCapabilities.edge());

driver.get("http://xyz.in");

在执行行 driver = new EdgeDriver(service, DesiredCapabilities.edge()); 时,边缘浏览器在执行失败后启动,错误为

'FAILED: test
org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.98 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'ODERWin10', ip: '192.168.1.119', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_13'
Driver info: org.openqa.selenium.edge.EdgeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
at Pack1.CrossBrowserTest.test(CrossBrowserTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)'

请提出解决方案,提前致谢

最佳答案

Selenium 2.48.2 将 Windows 10 识别为 Windows 8,我遇到了同样的错误。我能够让 Edge 打开而不挂起的唯一方法是手动打开 MicrosoftWebDriver.exe 文件,然后输入它告诉我它正在监听的任何 URL:

DesiredCapabilities browser = DesiredCapabilities.edge();
browser.setBrowserName(DesiredCapabilities.edge().getBrowserName());
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:17556"), browser);

关于java - Selenium webdriver 启动边缘浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34290957/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com