Selenium grid with Chrome driver (WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property)

前端 未结 6 770
孤城傲影
孤城傲影 2020-12-14 13:09

I am trying to get my Selenium Grid running on Chrome driver.

At first I started hub and node: java -jar selenium-server-standalone-2.45.0.jar -role hub java -jar se

相关标签:
6条回答
  • 2020-12-14 13:45

    Instead of specifying the driver executable in the cmd command, better approch would be :

    java -jar **selenium-server-standalone-3.8.1.jar** -role node  -hub http://localhost:4444/grid/register
    

    Save this as a .bat file and keep all the required Driver executable in the **same folder as the bat file**.

    No when you double click the bat file to start the node, it will pick up the executables automatically.

    0 讨论(0)
  • 2020-12-14 13:50

    I could run chrome and firefox remotely using selenium grid when I added both properties in json config file like this way here: notice the last two lines

    {
      "capabilities":
      [
        {
          "browserName": "firefox",
          "marionette": true,
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "chrome",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "internet explorer",
          "platform": "WINDOWS",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "safari",
          "technologyPreview": false,
          "platform": "MAC",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
        }
      ],
      "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
      "maxSession": 5,
      "port": -1,
      "register": true,
      "registerCycle": 5000,
      "hub": "http://192.168.1.2:4444",
      "nodeStatusCheckTimeout": 5000,
      "nodePolling": 5000,
      "role": "node",
      "unregisterIfStillDownAfter": 60000,
      "downPollingLimit": 2,
      "debug": false,
      "servlets" : [],
      "withoutServlets": [],
      "custom": {},
      "webdriver.gecko.driver":"c:/drivers/geckodriver.exe",
      "webdriver.chrome.driver":"c:/drivers/chromedriver.exe"
    }
    
    0 讨论(0)
  • 2020-12-14 13:51

    This works for me in 3.3.1 and above

    java -Dwebdriver.chrome.driver="C:\chromedriver.exe" -jar selenium-server-standalone-2.45.0.jar -role node -hub localhost:4444/grid/register -browser "browserName=chrome,version=ANY,platform=WINDOWS,maxInstances=20" -maxSession 20
    

    Webdriver path should be placed before the -jar options

    0 讨论(0)
  • 2020-12-14 13:54

    You can start your node as:

    java -jar selenium-server-standalone-2.45.0.jar -role node -hub localhost:4444/grid/register -browser "browserName=chrome,version=ANY,platform=WINDOWS,maxInstances=20" -Dwebdriver.chrome.driver="C:\chromedriver.exe" -maxSession 20
    
    0 讨论(0)
  • 2020-12-14 13:54

    You can set the path to the folder containing the chromedriver executable in your System variables (for Windows).

    That got rid of the error for me.

    0 讨论(0)
  • 2020-12-14 14:06

    The driver executable needs to be avaiable physically on node machine. You can set the path to exe while starting the node

    Add this line in the command

    -Dwebdriver.chrome.driver=./chromedriver.exe

    I configure this from json file and found that's little easier

    json file with name DefaultNode.json

    {
      "capabilities":
          [
            {
              "browserName": "firefox",
              "maxInstances": 5,
              "seleniumProtocol": "WebDriver"
            },
            {
              "browserName": "chrome",
              "maxInstances": 5,
              "seleniumProtocol": "WebDriver"
            },
            {
              "platform": "WINDOWS",
              "browserName": "internet explorer",
              "maxInstances": 1,
              "seleniumProtocol": "WebDriver"
            }
          ],
      "configuration":
      {
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 5,
        "port": 5555,
        "host": ip,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444,
        "hubHost": ip
      }
    }
    

    To start the node with json config

    java -jar selenium-server-standalone-2.45.0.jar -role webdriver -nodeConfig DefaultNode.json -Dwebdriver.ie.driver=.\IEDriverServer.exe
    

    Notice the IEDriverServer.exe is placed in same directory with json file

    0 讨论(0)
提交回复
热议问题