Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I'm using Firefox 47.0 with Selenium 2.53. Recently they have been a bug between Selenium and Firefox which make the code not working. One of the solutions is to use the Marionnette driver.

I followed the instruction of this site to use this new driver with a RemotWebDriver but I keep having the error :

WARN - Exception: Exception in thread "main" org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/jgraham/wires. The latest version can be downloaded from ....

The code I've tried so far is very simple :

public class Test {

    static WebDriver driver;

    static Wait<WebDriver> wait;

    public static void main(String[] args) throws MalformedURLException {

        System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");

        DesiredCapabilities cap = DesiredCapabilities.firefox();

        cap.setCapability("marionette", true);

        cap.setBrowserName("firefox");

        driver = new RemoteWebDriver(new URL("http://192.168.117.135:5555/wd/hub"), cap);//true to enable the JS

        wait = new WebDriverWait(driver, 3000);

        final String url = "https://www.google.com/";

        JavascriptExecutor js = (JavascriptExecutor) driver;

        try {

            driver.navigate().to(url);

        } finally {

            driver.close();

        }

    }

}

I'm sure that the path to the geckodriver.exe is right and I don't see where I did the mistake.

EDIT 1: I tried the following code :

public class Test {

    static WebDriver driver;

    static Wait<WebDriver> wait;

    public static void main(String[] args) throws MalformedURLException {

        System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");

        driver = new MarionetteDriver();

        wait = new WebDriverWait(driver, 3000);

        final String url = "https://www.google.com/";

        JavascriptExecutor js = (JavascriptExecutor) driver;

        try {

            driver.navigate().to(url);

        } finally {

            driver.close();

        }

    }

}

and it's working it seems that the problem comes from the RemoteWebDriver and the gecko driver, any of you have news on it?

1 Answer

0 votes
by (62.9k points)

If you are using Selenium 3 then to work with the Firefox browser you need to use separate a driver that will interact with the Firefox browser. If you have noticed then we have done the same thing for Chrome and IE browser as well.

One important thing in this post is even if you are using the Firefox beta version then it will work. If you are using Firefox 47 and so on then it will work.

We have used below system property for Chrome and IE

webdriver.chrome.driver for Chrome browser

 webdriver.ie.driver for IE browser

Now we have to use webdriver.gecko.driver for Firefox as well 

 Note- if you are still using Selenium 2 like 2.53 and 2.51 or any version then you don’t have to set this path.

Let’s run a basic program with Selenium 3 beta version

Program 1 without any driver:

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Test1 {

 

  public static void main(String[] args) {

  WebDriver driver = new FirefoxDriver();

 

       driver.get("http://www.google.com");

 

       driver.quit();

 

    }

 

}

Firefox in Selenium using geckodriver

As you can see to work with Firefox we have to set the property now.  You can download the driver from Github and then you can extract and you will get .exe file.

Download URL – https://github.com/mozilla/geckodriver/releases/tag/v0.9.0

Firefox in Selenium using geckodriver

Firefox in Selenium using geckodriverComplete program for Firefox in Selenium using geckodriver

import org.openqa.selenium.WebDriver;

 

import org.openqa.selenium.firefox.FirefoxDriver;

 

 

 

public class Test1 {

 

 

 

      public static void main(String[] args) {

 

 

              System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe");

             

              // if above property is not working or not opening the application in browser then try below property

 

          //System.setProperty("webdriver.firefox.marionette","G:\\Selenium\\Firefox driver\\geckodriver.exe");

 

            WebDriver driver = new FirefoxDriver();

 

            driver.get("http://www.facebook.com");

 

            System.out.println("Application title is ============="+driver.getTitle());

 

            driver.quit();

 

      }

 

}

 Now you can run the program and you will get the expected output.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium training and certification!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...