出现错误org.openqa.selenium.WebDriverException:转发新会话时出错设置虚拟机的空池用于Firefox的功能

时间:2019-09-18 12:05:34

标签: java selenium selenium-grid selenium-firefoxdriver

我正在使用: 的java:1.8 硒:3.141.59罐 Geco驱动程序版本:0.25.0 Firefox版本:69.0.1

下面是execute.bat文件的详细信息:

start java -jar C:/eclipse-workspace/Selenium_Grid/Config/selenium-server-standalone-3.141.59.jar -role hub

start java -Dwebdriver.chrome.driver=D:/Selenium/chromedriver_win32/chromedriver.exe -jar C:/eclipse-workspace/Selenium_Grid/Config/selenium-server-standalone-3.141.59.jar -role node -hub http://localhost:4444/grid/register -port 5558 -maxSession 5 -browser browserName=chrome,maxInstances=10 

start java -Dwebdriver.gecko.driver=D:/Selenium/geckodriver-v0.25.0-win64/geckodriver.exe -jar C:/eclipse-workspace/Selenium_Grid/Config/selenium-server-standalone-3.141.59.jar -role node -hub http://localhost:4444/grid/register -port 5559 -maxSession 5

Configuration of Grid Hub and node

下面是代码:

public static RemoteWebDriver getBrowserDriver(final String browser)
        throws MalformedURLException {
    return new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),
            getBrowserCapabilities(browser));
}

private static DesiredCapabilities getBrowserCapabilities(
        final String browserType) throws MalformedURLException {
    switch (browserType.toLowerCase()) {
    case "firefox":
        System.out.println("Opening firefox driver");
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities.setBrowserName("firefox");
        capabilities.setPlatform(Platform.WIN10);       
        return capabilities;
    }
}

正在运行的代码进入以下异常日志:

  

org.openqa.selenium.WebDriverException:转发新会话时出错,为安装程序设置了虚拟机空池{acceptInsecureCerts:true,browserName:firefox,marionette:true,平台:WIN10,版本:}   命令持续时间或超时:801毫秒   内部版本信息:版本:'3.141.59',修订版本:'e82be7d358',时间:'2018-11-14T08:25:48'   系统信息:主机:'GP-PIN-IS04',ip:'192.168.250.72',操作系统名称:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version: '1.8.0_221'   驱动程序信息:driver.version:RemoteWebDriver   由以下原因引起:org.openqa.grid.common.exception.GridException:错误转发新会话用于设置功能的虚拟机空池{acceptInsecureCerts:true,browserName:firefox,

1 个答案:

答案 0 :(得分:0)

因此您的错误显示为“错误转发新会话以设置功能的VM空池”,这意味着它正在寻找与创建远程驱动程序时所需的功能相匹配的节点,但找不到该节点。在启动geckodriver的行中,您没有指定像Chrome浏览器那样的浏览器。像这样启动节点时,创建节点配置文件并传递给它可能会更容易:

java -Dwebdirver.gecko.driver="D:/Selenium/geckodriver-v0.25.0-win64/geckodriver.exe" -jar selenium-server-standalone-3.8.1.jar -role node -hub "http://localhost:4444/grid/register/" -port 5559 -nodeConfig config.json

以下是您的firefox节点的配置文件:

 {
 "capabilities": [
   {
     "browserName": "firefox",
     "platform": "WIN10",
     "maxInstances": 5
   }      
 ],
 "hub": "http://<hub ip>:<hub port>"
 }