节点未与Selenium Grid中的集线器连接。出现“无法注册此节点:集线器已关闭或没有响应”错误

时间:2019-12-30 17:12:04

标签: selenium selenium-grid

我试图在两个Win 10系统中创建集线器节点连接,所以我在两个系统和一个我键入的系统中都下载了Selenium Standalone Server 3.141.59:

java -jar selenium-server-standalone-3.141.59.jar -role hub

所以我得到以下输出:

    22:04:20.353 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
22:04:20.504 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4444
2019-12-30 22:04:20.930:INFO::main: Logging initialized @900ms to org.seleniumhq.jetty9.util.log.StdErrLog
22:04:21.729 INFO [Hub.start] - Selenium Grid hub is up and running
22:04:21.731 INFO [Hub.start] - Nodes should register to http://192.xxx.xxx.x:4444/grid/register/
22:04:21.731 INFO [Hub.start] - Clients should connect to http://192.xxx.xxx.x:4444/wd/hub

在那之后,在我的节点系统(也是Win 10)中,我使用了以下命令:

java -Dwebdriver.chrome.driver="C:\Users\debuk\Downloads\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.xxx.xxx.x:4444/grid/register -port 7777

我遇到以下错误:

C:\Users\debuk\Downloads>java -Dwebdriver.chrome.driver="C:\Users\debuk\Downloads\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://192.xxx.xxx.x:4444/grid/register -port 7777
21:39:55.251 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
21:39:55.418 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 7777
2019-12-30 21:39:56.912:INFO::main: Logging initialized @2118ms to org.seleniumhq.jetty9.util.log.StdErrLog
21:39:57.250 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
21:39:57.360 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 7777
21:39:57.360 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
21:39:57.716 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
21:40:19.059 WARN [SelfRegisteringRemote.registerToHub] - Error getting the parameters from the hub. The node may end up with wrong timeouts.Failed to connect to /192.xxx.xxx.x:4444
21:40:19.060 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://192.xxx.xxx.x:4444/grid/register
21:40:40.092 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: Failed to connect to /192.xxx.xxx.x:4444
21:41:06.111 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to /192.xxx.xxx.x:4444
21:45:38.322 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to /192.xxx.xxx.x:4444

*我都打开了存在独立服务器的cmd。 谁能对此有任何解决方案?我也尝试过selenium-server-standalone-2.39.0,也面临同样的问题。

2 个答案:

答案 0 :(得分:0)

要连接节点,可以使用以下命令:

java -Dwebdriver.chrome.driver =“ chromedriver路径” -jar selenium3.14.jar(path)-角色节点-nodeConfig json文件路径

为以下功能创建一个json文件:

{
  "capabilities":
  [

    {
      "browserName": "chrome",
      "maxInstances": 30,
      "seleniumProtocol": "WebDriver",
      "platform":"WINDOWS"
    }
  ],

  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 30,
  "port": 5555,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://**ip of hub**",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
  }

此代码对我有用,您也可以将其用于其他浏览器,只需更改浏览器名称即可。

答案 1 :(得分:0)

我在您的命令中没有发现任何重大问题。但是,您可能需要考虑以下两项更改:

  • -role webdriver
  • 替换-role node
  • 删除 chromedriver.exe
  • 周围的双引号

详细步骤

确保执行以下步骤:

  • 启动 Selenium Grid Hub

    java -jar selenium-server-standalone-3.141.59.jar -role hub
    
  • 生成的日志:

    18:10:13.310 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
    18:10:13.618 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4444
    2020-01-02 18:10:14.605:INFO::main: Logging initialized @2136ms to org.seleniumhq.jetty9.util.log.StdErrLog
    18:10:15.504 INFO [Hub.start] - Selenium Grid hub is up and running
    18:10:15.509 INFO [Hub.start] - Nodes should register to http://192.168.1.125:4444/grid/register/
    18:10:15.510 INFO [Hub.start] - Clients should connect to http://192.168.1.125:4444/wd/hub
    
  • 通过URL http://localhost:4444/grid/console访问 Selenium Grid Console v.3.141.59

SeleniumGridConsole

  • 启动硒网格节点

    java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.141.59.jar -role node -port 7777 -hub http://192.168.1.125:4444/grid/register
    
  • 生成的日志:

    18:33:55.959 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
    18:33:56.112 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 7777
    2020-01-02 18:33:56.584:INFO::main: Logging initialized @983ms to org.seleniumhq.jetty9.util.log.StdErrLog
    18:33:56.913 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
    18:33:57.029 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 7777
    18:33:57.029 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
    18:33:57.195 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
    18:33:57.734 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://192.168.1.125:4444/grid/register
    18:33:57.856 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
    
  • 通过URL http://localhost:4444/grid/console再次访问 Selenium Grid Console v.3.141.59 ,以查看注册的节点:

SeleniumGridConsole_NodeRegistered