当前位置: 首页 > 面试题库 >

SessionNotCreatedException:无法创建新服务:Ubuntu上具有Selenium Grid的GeckoDriverService无法驱动Firefox

薛弘厚
2023-03-14
问题内容

我无法使用geckodriver从Selenium驱动Firefox。这很奇怪,因为chrome是由相同的框架驱动的,没有错误!

这些是我的版本号:

Firefox 54.0 (64-bit)
Chrome Version 62.0.3202.94 (Official Build) (64-bit)

selenium-server-standalone-3.7.1.jar
client-combined-3.5.3-nodeps.jar

geckodriver-v0.19.1-linux64
chromedriver_linux64

Ubuntu 16.10

我使用Java从Selenium Webdriver获得的错误如下:

--------------------------------Error:
leder@leder-VirtualBox:~/Source/SeleniumCheese/bin$ ./execute_grid.sh 
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: GeckoDriverService
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'leder-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-59-generic', java.version: '1.8.0_131'
Driver info: driver.version: unknown
Command duration or timeout: 1.39 seconds
---------------------------------Schnapp

这是我的设置,Firefox坏了,chrome可以了:

Grid_SetUp.java

package de.auticon.selenium_server;
import org.openqa.selenium.WebDriver;    
import org.openqa.selenium.By;   
import org.openqa.selenium.WebElement;   
import org.openqa.selenium.remote.DesiredCapabilities;    
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;    
import java.net.URL;

public class Grid_SetUp {   
    public static WebDriver driver;

    public static void main(String[]  args) throws MalformedURLException, InterruptedException{   
        System.setProperty("webdriver.chrome.driver","/opt/selenium/chromedriver");    
        String URL = "http://www.google.de";    
        String Node = "http://192.168.40.40:4444/wd/hub";    
        DesiredCapabilities cap = DesiredCapabilities.firefox();   
        driver = new RemoteWebDriver(new URL(Node), cap);
        driver.navigate().to(URL);
        WebElement element = driver.findElement(By.name("q"));
        //Enter something to search for
        element.sendKeys("Cheese!");
        // Now submit the form. WebDriver will find the form for us from the element
        element.submit();
        // Check the title of the page
        System.out.println("Page title is: " + driver.getTitle());

        Thread.sleep(5000);

        driver.quit();    
    }    
}

selenium_grid.sh:

#!/bin/bash
java -jar /opt/selenium/selenium-server-standalone-3.7.1.jar -role hub &
java -Dwebdriver.gecko.driver=/opt/selenium/geckodriver -jar /opt/selenium/selenium-server-standalone-3.7.1.jar -role webdriver -hub http://192.168.40.40:4444/grid/register -nodeConfig /opt/selenium/defaultNodeConfig.json -browser "browserName=firefox,platform=LINUX" &

execute_grid.sh:

#!/bin/bash
java -cp ".:/opt/selenium/selenium-server-standalone-3.7.1.jar" de.auticon.selenium_server.Grid_SetUp

我现在更新了工作配置的问题。但是,当运行firefox Selenium TC时,TC完成了,不幸的是服务器以错误消息“会话未创建”结束:

13:49:10.376 INFO - Removing session org.openqa.selenium.remote.server.ServicedSession@70c81601
13:49:10.381 INFO - To downstream: {"value":{"error":"session not created","message":"Tried to run command without establishing a connection","stacktrace":"stack backtrace:\n   0:           0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e\n   1:           0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46\n   2:           0x4409a1 - webdriver::error::WebDriverError::new::h81babdd86c977032\n   3:           0x4280ea - <webdriver::server::Dispatcher<T, U>>::run::h2119c674d7b88193\n   4:           0x4029b9 - std::sys_common::backtrace::__rust_begin_short_backtrace::h21d98a9ff86d4c25\n   5:           0x40be65 - std::panicking::try::do_call::h5cff0c9b18cfdbba\n   6:           0x5e6a6c - panic_unwind::__rust_maybe_catch_panic\n                        at /checkout/src/libpanic_unwind/lib.rs:99\n   7:           0x41eb22 - <F as alloc::boxed::FnBox<A>>::call_box::h413eb1d9d9f1c473\n   8:           0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>\n                        at /checkout/src/liballoc/boxed.rs:692\n                         - std::sys_common::thread::start_thread\n                        at /checkout/src/libstd/sys_common/thread.rs:21\n                         - std::sys::imp::thread::{{impl}}::new::thread_start\n                        at /checkout/src/libstd/sys/unix/thread.rs:84"}}

问题答案:

关于Selenium Grid配置的几句话:

  • 您提到了Test Bedas selenium-server-standalone-3.7.1.jarclient-combined-3.5.3-nodeps.jar。按照Best Practices,您应该使用以下 两个选项之一

  • 始终尝试使用最新发布的版本,即 selenium-server-standalone-3.7.1.jar

  • selenium_grid.sh: 您需要更改以下内容:

    java -Dwebdriver.gecko.driver=/opt/selenium/geckodriver
    


 类似资料:
  • 问题内容: 嗨,任何人都知道这是怎么回事或如何调试以下错误。我所做的步骤是使用安装中心命令并将节点注册到中心。在命令注册节点之后。我可以看到日志为 但是,当我运行测试脚本时,出现以下错误: 二进制版本: selenium独立版本:3.14.0 selenium远程驱动程序版本:selenium== 3.14.1 python版本:3.6.4 脚本: 设置中心: 注册节点: 错误: 问题答案: 此错

  • 无论我尝试什么;最新的chrome浏览器,最新的chromedriver,最新的selenium服务器,等等。但是当我在Mac OSX上运行测试时,我不断得到上面的错误。我研究过其他类似的问题,甚至尝试过那里提出的解决方案,但似乎没有任何效果。我错过了什么或做错了什么?? 以下是我的设置: Chrome版本:75.0.3770.100(最新版本) Chromedriver版本:75.0.3770.

  • 我知道这个问题以前被问过多次,但没有一个解决方案对我有帮助。 3个月前,我成功地做到了这一点,但现在我陷入了困境,没有改变任何让我困惑的事情,我真的不知道该怎么办! 1:基本信息:win 7 Rselenium standalone 3.13.0(试用过3.9.1,但不起作用,三个月前就开始工作了)chrome版本v64。0.3282.140(32位)chromedriver 2.37应兼容。(还

  • 我想设置两台运行jstatd的服务器,这样我就可以动态监控我的应用程序。web服务器已经启动并运行,但另一台服务器总是会出现这样的异常。 无法将/JStatRemoteHost绑定到RMI注册表java。rmi。ServerException:服务器线程中发生RemoteException;嵌套的例外是:java。rmi。解组异常:错误解组参数;嵌套的例外是:java。lang.ClassNotF

  • 我想请求帮助一个问题,我在没有接口的windows服务器上运行selenium,我得到以下错误: 无法在http://localhost:49906/at openqa.selenium.driverservice.start()at openqa.selenium.remote.driverserviceCommandExecute(命令commandToExecute)at openqa.se

  • 使用selenium grid在windows节点和mac节点上并行运行测试将通过所有测试,但无法运行并跳过mac Firefox浏览器或windows Firefox浏览器的第一个测试过滤器MoreResultsBySquarefeet。它不断抛出这个错误。openqa。硒。SessionNotCreatedException:无法创建新服务:GeckoDriverService我正在使用最新的