Search code examples
javalinuxfirefoxselenium-grid

Java - Unable to use selenium grid with firefox browser


I am trying to run firefox (version 64.0) with selenium grid. The browser is getting opened but not loading any webpages. Can someone tell me what I am missing? This is how I obtain the Webdriver object.

public WebDriver getWebDriverInstance()
{
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    String url = "http://localhost:4444/wd/hub";
    WebDriver wd = new RemoteWebDriver(new URL(url),dc);
    return wd;
}

I am using selenium grid version 3.11.0.

The command I used for starting the hub: java -jar selenium-server-standalone-3.11.0.jar -role hub
and for starting the node: java -jar selenium-server-standalone-3.11.0.jar -role node -hub http://localhost:4444/grid/reister -browser platform=LINUX.

If I replace DesiredCapabilities.firefox() with DesiredCapabilities.chrome(), my chrome browser is running the test cases correctly. I don't want to specify the browser type in my shell command because the browser version will be determined during the runtime.


Solution

  • The problem was because of the geckodriver. The path to geckodriver cannot be passed as argument in the command because the browser type will be known only in the runtime.

    So update the firefox browser and download the latest geckodriver version from here. Extract the zip and paste it in

    /usr/bin

    This solution works for linux.