简体   繁体   English

SessionNotCreatedException:无法创建新服务:GeckoDriverService

[英]SessionNotCreatedException: Unable to create new service: GeckoDriverService

I'm using:我正在使用:

  • Java 1.8爪哇 1.8
  • Selenium 3.5.0硒 3.5.0
  • Selenium Standalone Server 3.5.0 Selenium 独立服务器 3.5.0
  • OS for selenium hub - RHEL 7硒集线器的操作系统 - RHEL 7
  • Geckodriver 18壁虎驱动器 18
  • Firefox 55火狐 55

I have an error:我有一个错误:

    org.openqa.selenium.SessionNotCreatedException: Unable to create new service: GeckoDriverService
    Build info: version: '3.5.0', revision: '8def36e068', time: '2017-08-10T23:00:22.093Z'
    System info: host: 'NC9128105064', ip: '9.128.105.64', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.el7.x86_64', java.version: '1.8.0_91'
    Driver info: driver.version: unknown
    Command duration or timeout: 16 milliseconds
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
        at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
        at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
        at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:360)
        at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
        at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
        at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
        at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:363)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:137)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:641)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:254)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:174)
        at Utils.BrowserDriver.ff(BrowserDriver.java:66)
        at TestCases.Category.LogInCreateCategory.logIn(LogInCreateCategory.java:29)
        at TestCases.TestRunner.main(TestRunner.java:82)

Code for chosing firefox:选择firefox的代码:

            public static WebDriver ff() {

            File firefoxfile = new File(PropertyReader.getProperty("firefox"));
            System.setProperty("webdriver.gecko.driver", firefoxfile.getPath());

            WebDriver wd = null;//new RemoteWebDriver(dc);

            try {
                URL url = new URL("http://" + TestRunner.SELENIUM_HUB + ":4444/wd/hub");
                FirefoxProfile fp = new FirefoxProfile();
                // set something on the profile...
                DesiredCapabilities dc = DesiredCapabilities.firefox();
                dc.setCapability("marionette", true);
                //dc.setCapability(FirefoxDriver.PROFILE, fp);

                wd = new RemoteWebDriver(url, dc);
            } catch (MalformedURLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            return wd;
    }

I think that something is wrong with the path to the geckodriver on Linux.我认为 Linux 上 geckodriver 的路径有问题。 I tried couple options like:我尝试了几个选项,例如:

  • /drivers/geckodriver
  • drivers/geckodriver
  • root/drivers/geckodriver
    but with no success但没有成功

The pwd in dir with geckodriver on Linux gives me: Linux 上带有 geckodriver 的 dir 中的pwd给了我:
/root/drivers

please update geckodriver to the latest version.请将 geckodriver 更新到最新版本。

File firefoxfile = new File(PropertyReader.getProperty("C://users//geckodriver.exe"));
 System.setProperty("webdriver.gecko.driver", firefoxfile.getPath());

I faced the same issue and resolved it by setting the system property to geckodriver.exe path as given below:我遇到了同样的问题并通过将系统属性设置为geckodriver.exe路径来解决它,如下所示:

System.setProperty("webdriver.gecko.driver","C:\\tech2\\selenium\\geckodriver.exe");

Set the property before instantiating the driver.在实例化驱动程序之前设置属性。

I found the solution here .我在这里找到了解决方案。 The issue seems specific to selenium 3.x+.该问题似乎特定于 selenium 3.x+。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SessionNotCreatedException:无法创建新服务:在 Ubuntu 上使用 Selenium Grid 的 GeckoDriverService 无法驱动 Firefox - SessionNotCreatedException: Unable to create new service: GeckoDriverService with Selenium Grid on Ubuntu failing to drive Firefox 继续获取SessionNotCreatedException:无法创建新服务:ChromeDriverService错误 - Keep getting SessionNotCreatedException: Unable to create new service: ChromeDriverService error SessionNotCreatedException:无法创建新的远程 session - SessionNotCreatedException: Unable to create a new remote session SessionNotCreatedException: 无法创建新的远程会话。 Appium 1.15.1 Jenkins 检测过程无法初始化错误 - SessionNotCreatedException: Unable to create a new remote session. The instrumentation process cannot be initialized error with Appium 1.15.1 Jenkins WinAppDriver:org.openqa.selenium.SessionNotCreatedException:无法创建新的远程 session - WinAppDriver: org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session Appium 错误:线程“main”org.openqa.selenium.SessionNotCreatedException 中的异常:无法创建新的远程会话 - Appium Error :Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session org.openqa.selenium.SessionNotCreatedException:无法创建新的远程会话。 在模拟器中初始化android驱动程序 - org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. while initializing android driver in emulator Selenium 3.0 Firefx 驱动程序因 org.openqa.selenium.SessionNotCreatedException 失败:无法创建新的远程会话 - Selenium 3.0 Firefx Driver fails with org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session org.openqa.selenium.SessionNotCreatedException:无法在Mac中创建新的远程会话 - org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session in Mac 如何修复 SessionNotCreatedException:尝试运行 Firefox 时无法创建新的远程 session? - How to fix SessionNotCreatedException: Unable to create new remote session when trying to run Firefox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM