硒网格 3 节点中的 Chromedriver 设置

Chromedriver setup in selenium grid 3 node

我的StartSeleniumGridNode.bat文件。

java -jar selenium-server-standalone-3.4.0.jar -role node -hub http://127.0.0.1:4444/grid/register ^
-browser "browserName=firefox,maxInstances=3,platform=WINDOWS" ^
-browser "browserName=chrome,maxInstances=2,platform=WINDOWS" -Dwebdriver.chrome.driver="D:\SeleniumGridPractice\drivers\chromedriver.exe"

这是我在控制台中遇到的错误。

D:\SeleniumGridPractice>StartSeleniumGridNode.bat
D:\SeleniumGridPractice>java -jar selenium-server-standalone-3.4.0.jar -ro
le node -hub http://127.0.0.1:4444/grid/register -browser "browserName=firefox,m
axInstances=3,platform=WINDOWS" -browser "browserName=chrome,maxInstances=2,plat
form=WINDOWS" -Dwebdriver.chrome.driver="D:\SeleniumGridPractice\drivers\c
hromedriver.exe"
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown opti
on: -Dwebdriver.chrome.driver=D:\SeleniumGridPractice\drivers\chromedriver
.exe
        at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
        at com.beust.jcommander.JCommander.parse(JCommander.java:282)
        at com.beust.jcommander.JCommander.parse(JCommander.java:265)
        at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
        at org.openqa.grid.selenium.GridLauncherV3.setConfiguration(GridLaunch
erV3.java:267)
        at org.openqa.grid.selenium.GridLauncherV3.buildLauncher(GridLauncherV3.
java:155)
        at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:75)`

D:\SeleniumGridPractice>

注意:StartSeleniumGridHub.bat 完美地 运行。 Firefox 也没有问题。

请更改

java -jar selenium-server-standalone-3.4.0.jar -role node -hub http://127.0.0.1:4444/grid/register -browser "browserName=firefox,maxInstances=3,platform=WINDOWS" -browser "browserName=chrome,maxInstances=2,platform=WINDOWS" -Dwebdriver.chrome.driver="D:\SeleniumGridPractice\drivers\chromedriver.exe"

java -Dwebdriver.chrome.driver="D:\SeleniumGridPractice\drivers\chromedriver.exe" -jar selenium-server-standalone-3.4.0.jar -role node -hub http://127.0.0.1:4444/grid/register -browser "browserName=firefox,maxInstances=3,platform=WINDOWS" -browser "browserName=chrome,maxInstances=2,platform=WINDOWS"

然后重试。

解释:

JVM 参数(以 -D 开头的参数)应该在 -jar 参数之前提供。但是由于您在 -jar 之后提供了它,而不是将其视为 JVM 参数,因此它被作为命令行参数提供给 selenium-server 独立 jar。