My StartSeleniumGridNode.bat file.
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:SeleniumGridPracticedriverschromedriver.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:SeleniumGridPracticedriversc
hromedriver.exe"
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown opti
on: -Dwebdriver.chrome.driver=D:SeleniumGridPracticedriverschromedriver
.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$3.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运行良好。火狐也没有问题。
请更改
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:SeleniumGridPracticedriverschromedriver.exe"
自
java -Dwebdriver.chrome.driver="D:SeleniumGridPracticedriverschromedriver.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。