GeckoDriver: FAQs & Set up Guide in Selenium 3 for Latest Firefox

An Older version of Selenium like Webdriver 2.51 is working fine till Mozilla Firefox version 45. So it was difficult for Automation Engineer to run tests on the latest version of Firefox. Therefore, by considering all these constraints Mozilla introduced an executable proxy web browser engine, named Geckodriver. It addressed all the problems of running test cases with the latest version of Mozilla Firefox.

 Selenium 3 Inviul Geckodriver

What is GeckoDriver?

Geckodriver is the next generation of FirefoxDriver. It gives HTTP API WebDriver protocol support to communicate with Gecko based browsers. It is mainly a proxy for W3C WebDriver compatible clients which mainly interacts with Gecko browsers.

Selenium project team worked in tandem with Mozilla developers to make Selenium compatible with W3C WebDriver standard. Hence they launched Selenium 3 and continuously working to provide the best compliance in their 3.X.X versions.

GeckoDriver supported by Marionette, which is the protocol of Firefox.

See Change logs

WebDriver Capabilities Definition for Latest Firefox

 

How does GeckoDriver work?

Selenium 3 does not have any native implementation of Firefox browser. Hence, all the driver commands are directed through GeckoDriver. Thus, It works as a proxy between your test cases and Firefox browser.

Selenium 3 removed native implementation of Firefox browser to avoid any kind of driver conflicts. Ultimately, WebDriver API became a light weight.

 

How to set up GeckoDriver?

It is an executable file which is available to download. So download the file and store it in your system. Then define the path of the .exe file. Firefox implements the WebDriver protocol with this driver.

This executable file creates an environment and starts a server on your system. All your WebDriver tests firstly communicate to this server. It further acts as a proxy between the local system and remote, thus, it sends translated test data using Marionette automation protocol.

 

How to initialize GeckoDriver in code?

You need to set up system property for this. Here is the code snippet that you need to define initially.

System.setProoerty(“webdriver.gecko.driver”, “Path of geckodriver executable file”);

WebDriver driver = new FirefoxDriver();

Example:

System.setProoerty(“webdriver.gecko.driver”, "F:\\geckodriver.exe");

WebDriver driver = new FirefoxDriver();

 

TIP: Press Shift and right click on Geckodriver.exe file and select “Copy as Path”. Entire path will be copied then replace single slash ‘\’ by double slash ‘\\’.

 

What error will it throw if I don’t use GeckDriver with latest Firefox and Selenium 3?

Java throws IllegalStateException if you don’t use GeckoDriver with Selenium 3 and Latest Firefox. As said above, Selenium 3 does not have a local implementation to Firefox browser.

Here is the screenshot from console:

 Geckodriver error console

How to Set up System property in Java for GeckoDriver?

You need to initialize System.setProperty() method before initializing WebDriver command on FirefoxDriver() instantiation.

Here is the code snippet for basic URL open test case:

package InviulTest;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirefoxTest {

	public static void main(String[] args) {
		System.setProperty("webdriver.gecko.driver", "F:\\geckodriver.exe");
		WebDriver driver = new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
		driver.navigate().to("http://www.inviul.com");
		driver.manage().window().maximize();
		driver.close();
		driver.quit();
	}
}

Here is the screenshot from console when you successfully implements Marionette in your test case;

Geckodriver successfully set up with Selenium 3

I believe you got clarification to all your questions related to Selenium 3, Latest Firefox, FirefoxDriver() and GeckoDriver (Binary version of Marionette driver). Kindly share your doubts and feedback in the comment below and keep pushing yourself harder because ‘Default is Automation’.

Leave a Reply