gpt4 book ai didi

java - 使用 Selenium 3.0.0-beta3 的 Geckodriver 启动 Firefox 41 失败

转载 作者:行者123 更新时间:2023-11-30 06:51:55 27 4
gpt4 key购买 nike

我正在使用 WebDriver 运行一些快速测试。我下载了 FirefoxWebDriverChromeWebDrivergeckodriver-v0.10.0-win64.zipchromedriver_win32.zip

它们被提取到路径位置并相应地重命名; wires.exechromedriver.exe

当我创建我的测试时,做了如下操作:

DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(cap);

//WebDriver driver = new ChromeDriver(DeesiredCapabilities.chrome());

对于 Firefox,它未能创建 session (并且未通过测试),而 chrome 成功并通过了测试。

测试结果如下:

Sep 28, 2016 2:51:32 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Sep 28, 2016 2:51:38 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Sep 28, 2016 2:51:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.

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: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:57:44 -0700'
System info: host: 'CHI-CS-55DXX52', ip: '10.60.68.15', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: FirefoxDriver

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:231)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:219)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:214)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:131)
at com.polymerdart.webdriver.MyFirstTest.startWebDriver(MyFirstTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:57:44 -0700'
System info: host: 'CHI-CS-55DXX52', ip: '10.60.68.15', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:80)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:597)
... 34 more

我确实看到 Firefox 正在打开,但它无法创建 session 并关闭。我目前在这台机器上运行 Firefox version 41.0

最佳答案

这是Selenium3Mozilla Firefox版本之间的不兼容问题。

实际上Selenium3 支持可执行文件geckodriver像现在的其他驱动程序一样启动 Mozilla Firefox 但可执行 geckodriverMozilla Firefox >= v47 兼容,这就是你遇到麻烦的原因。

有两种方法可以解决这个问题:-

  • 将您的 selenium 版本降级到 Selenium2

  • 升级您的 Mozilla Firefox >= v47也尝试使用 Selenium3 并启动 FirefoxDriver,如下所示:-

    //Set system property with downloaded executable geckodriver from your system location 

    DesiredCapabilities cap = DesiredCapabilities.firefox();
    cap.setCapability("marionette", true);
    WebDriver driver = new FirefoxDriver(cap);

关于java - 使用 Selenium 3.0.0-beta3 的 Geckodriver 启动 Firefox 41 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39755884/

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