Rectangle 27 5

The solutions above work fine for local testing and firing up browsers from the java code.If you fancy firing up your selenium grid later then this parameter is a must have in order to tell the remote node where to find the geckodriver:

-Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe"

The node cannot find the gecko driver when specified in the Automation Java code.

So the complete command for the node whould be (assuming node and hub for test purposes live on same machine) :

java -Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe" -jar selenium-server-standalone-2.53.0.jar -role node -hub http://localhost:4444/grid/register

And you should expect to see in the node log :

00:35:44.383 INFO - Launching a Selenium Grid node
Setting system property webdriver.gecko.driver to C:\geckodriver\geckodriver.exe

The given syntax throw an exception with newer selenium-server versions (like 3.2.0): Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -Dwebdriver.gecko.driver=geckodriver.exe at com.beust.jcommander.JCommander.parseValues(JCommander.java:742) ... To avoid this, you need to change the arguments order (property declaration first, jar, and program args. after). Example: java -Dwebdriver.gecko.driver="./geckodriver.exe" -jar selenium-server-standalone-3.2.0.jar -role node -hub 10.64.201.100:4444/grid/register

java - How to use the gecko executable with Selenium - Stack Overflow

java selenium firefox geckodriver
Rectangle 27 5

The solutions above work fine for local testing and firing up browsers from the java code.If you fancy firing up your selenium grid later then this parameter is a must have in order to tell the remote node where to find the geckodriver:

-Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe"

The node cannot find the gecko driver when specified in the Automation Java code.

So the complete command for the node whould be (assuming node and hub for test purposes live on same machine) :

java -Dwebdriver.gecko.driver="C:\geckodriver\geckodriver.exe" -jar selenium-server-standalone-2.53.0.jar -role node -hub http://localhost:4444/grid/register

And you should expect to see in the node log :

00:35:44.383 INFO - Launching a Selenium Grid node
Setting system property webdriver.gecko.driver to C:\geckodriver\geckodriver.exe

The given syntax throw an exception with newer selenium-server versions (like 3.2.0): Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -Dwebdriver.gecko.driver=geckodriver.exe at com.beust.jcommander.JCommander.parseValues(JCommander.java:742) ... To avoid this, you need to change the arguments order (property declaration first, jar, and program args. after). Example: java -Dwebdriver.gecko.driver="./geckodriver.exe" -jar selenium-server-standalone-3.2.0.jar -role node -hub 10.64.201.100:4444/grid/register

java - How to use the gecko executable with Selenium - Stack Overflow

java selenium firefox geckodriver
Rectangle 27 0

Firstly say the issue in your code, if you want to use the selenium server/grid please specify the webdriver path in command line when start selenium server,rather than specify by code. so below code is unnecessary, they are only necessary when you choose run test not using selenium server/grid, we call it 'directConnect' (your script communicate directly with webdriver.exe)

if(browser.equals("firefox"))
        System.setProperty("webdriver.gecko.driver", 
    System.getProperty("user.dir")+"//geckoDriver//geckodriver");
    else if(browser.equals("chrome"))
        System.setProperty("webdriver.chrome.driver", 
    System.getProperty("user.dir")+"//chromeDriver//chromeDriver");
java
-Dwebdriver.chrome.driver=C:\selenium\chromedriver_2.32.exe 
-Dwebdriver.gecko.driver=C:\selenium\geckodriver-v0.18.0.exe 
-jar C:\selenium\selenium-server-standalone-3.4.0.jar 
-role node
-port 4446

Reminder: please check the standalone.jar, specified webdriver.exe and browser on node are compatible with each other, otherwise the node will fail to launch browser in testing.

Thanks for your help. Now I run this command and works for firefox but not for chrome,any idea . java -Dwebdriver.chrome.driver=Users/username/chromeDriver/chromedriver -Dwebdriver.gecko.driver=/Users/username/gecko_driver/geckodriver -jar /Users/username/selenium-server/selenium-server-standalone-3.5.3.jar -role node -port "+nodePort+" -hub localhost:"+hubPort+"/grid/register

please check the chromedriver compatibel with your chrome browser, my chrome version is 60 and chromedriver is 2.30

java - Not able to implement selenium grid - Stack Overflow

java selenium selenium-webdriver selenium-grid