Which version of Firefox is compatible with selenium


Compatibility of Firefox with Selenium has always been a pain area. Before Selenium3, Firefox used to be the default browser for Selenium. But after Selenium3, by using GeckoDriver explicitly, we can initialize the script in FireFox.

  • FireFox was fully supported only in previous versions i.e. v47 and earlier. Selenium WebDriver version 2.53 is not compatible with Mozilla FireFox version 47.0+. After v47.0, FireFox is provided with GeckoDriver. GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with gecko-based browsers i.e. Mozilla FireFox.

  • GeckoDriver acts a link between Selenium WebDriver tests and Mozilla FireFox Browser. It is a web browser engine which is inbuilt in FireFox Browser.

  • But here comes the question, why only GeckoDriver as opposed to FireFox’s default driver.The Answer to which is GeckoDriver uses W3C WebDriver protocol to communicate with Selenium, which allows Selenium Developers to allow the same WebDriver to run in multiple browser versions.

  • Let’s see, for Selenium 2.53.1 and before, how Selenium used to work with FireFox.

public class FirefoxTest {
   @Test
   public void startFfBrowser() {
      WebDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}

After running the code, FireFox opens google.com. But now if we run the same lines of code in Selenium3 and above, we will get a run time error.

“java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property;”

So for running the script in FireFox v47 and above, GeckoDriver comes into play.

public class FirefoxTest {
   @Test
   public void startFfBrowser () {
      System.setProperty("webdriver.gecko.driver",Path of your GeckoDriver.exe file);
      FirefoxDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}

We can improve this code by directly set the geckodriver path in our System’s Environment variable and use the traditional way to instantiate web driver.

Updated on: 07-Aug-2019

792 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements