Search code examples
javaseleniumselenium-gridremotewebdrivergeckodriver

unable to create new remote session with remotewebdriver and gecko driver


I am trying to migrate to selenium 3, however I am having problems with creating new remote session here is my code below:

 protected RemoteWebDriver driver;
    @Test
    public void testing() throws FileNotFoundException, IOException {

        System.setProperty("webdriver.gecko.driver", "C:\\java\\geckodriver.exe");
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setCapability("marionette", true);
        driver = new RemoteWebDriver(new URL("http://google.com"),capability);
        System.out.println();
    }

I am running a selenium grid and here is my command lines:

java -jar selenium-server-standalone-3.0.1.jar -role hub

thats for running the hub server.

java -Dwebdriver.firefox.marionette=true -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register

and that's for running the node. any help will be much appreciated.

Thanks


Solution

  • I found out and solved the issue, by changing the command line when running selenium node:

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

    I noticed that you don't even need to change your remotewebdriver instantiation your code could simply be as following:

    protected RemoteWebDriver driver;
    @Test
    public void testing() throws FileNotFoundException, IOException {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        driver = new RemoteWebDriver(new URL("http://google.com"),capability);
        System.out.println();
    }