我的 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$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 运行正常。 Firefox也没有问题。
答案 0 :(得分:0)
请更改
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。