Selenium Grid:无法通过浏览器客户端访问Hub URL /控制台

时间:2018-04-21 19:25:50

标签: selenium selenium-webdriver grid webdriver selenium-grid

我按照以下步骤开始使用selenium hub。启动selenium grid hub

  1. hub.json文件:

    {
    "port": 4441,
    "newSessionWaitTimeout": -1,
    "custom": {},
    "capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
    "throwOnCapabilityNotPresent": true,
    "cleanUpCycle": 5000,
    "role": "hub",
    "debug": false,
    "browserTimeout": 0,
    "timeout": 1800
     }
    
  2. 我解雇了命令:

    java -Dwebdriver.chrome.driver=E:\SELENIUM_DOWNLOADS\Drivers\chromedriver.exe -jar E:\SELENIUM_DOWNLOADS\Jars\selenium-server-standalone-3.11.0.jar -role hub -hubConfig hub.json
    
  3. 结果:

    E:\>cd \selenium_practice\Maven_Workspace\DataDriven_zoho_18April2019_GRID
    E:\selenium_practice\Maven_Workspace\DataDriven_zoho_18April2019_GRID>java -Dwebdriver.chrome.driver=E:\SELENIUM_DOWNLOADS\Drivers\chromedriver.exe -jar E:\SELENIUM_DOWNLOADS\Jars\selenium-server-standalone-3.11.0.jar -role hub -hubConfig hub.json
    00:40:48.652 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.11.0', revision: 'e59cfb3'
    00:40:48.652 INFO [GridLauncherV3$2.launch] - Launching Selenium Grid hub on port 4441
    2018-04-22 00:40:49.166:INFO::main: Logging initialized @1081ms to org.seleniumhq.jetty9.util.log.StdErrLog
    00:40:49.572 INFO [Hub.start] - Selenium Grid hub is up and running 
    00:40:49.572 INFO [Hub.start] - Nodes should register to http://192.168.1.10:4441/grid/register/
    00:40:49.572 INFO [Hub.start] - Clients should connect to http://192.168.1.10:4441/wd/hub
    
  4. 当我输入浏览器http://192.168.1.10:4441/grid/register/

    HTTP ERROR 500
    Problem accessing /grid/register. Reason:
    Server Error
    Caused by: java.lang.IllegalStateException: Not a JSON Object: null
    

1 个答案:

答案 0 :(得分:0)

通过自定义配置启动 Selenium Grid Hub 时,您需要考虑以下几点:

  • 您的 hub.json 文件看起来非常完美。
  • 启动 Selenium Grid Hub 时,您可以删除参数 -Dwebdriver ,如下所示:

    java -jar E:\SELENIUM_DOWNLOADS\Jars\selenium-server-standalone-3.11.0.jar -role hub -hubConfig hub.json
    
  • 您需要通过网址访问 Selenium Grid Hub控制台

    http://localhost:4441/grid/console
    
  • 要查看您需要访问网址的配置:

    http://localhost:4441/grid/console?config=true&configDebug=true
    
  • 根据 hub.json 文件 Selenium Grid Hub控制台配置的快照:

HubConfig