Download Geckodriver for Firefox & Selenium
โก Smart Summary
GeckoDriver for Firefox and Selenium acts as a proxy between W3C WebDriver clients and Mozilla Firefox, translating commands into the Marionette protocol. This guide explains installation, initialization techniques, sample code, common exceptions, and core compatibility advantages.

What is GeckoDriver in Selenium?
The term Gecko stands for a web browser engine built into the Mozilla Firefox browser. GeckoDriver acts as a proxy between WebDriver-enabled clients (Eclipse, NetBeans, IntelliJ IDEA, etc.) and the Mozilla Firefox browser. In short, GeckoDriver serves as a link between Selenium WebDriver tests and Mozilla Firefox.
Before Selenium 3, the Mozilla Firefox browser was the default browser for Selenium. After Selenium 3, testers must initialize the script to use Firefox through GeckoDriver explicitly. Selenium uses the W3C WebDriver protocol to send requests to GeckoDriver, which translates them into a protocol named Marionette. Firefox then understands the commands transmitted in the Marionette protocol format and executes them.
Advantage of Using GeckoDriver
Selenium WebDriver version 2.53 is not compatible with Mozilla Firefox version 47.0+. The legacy Firefox driver used in earlier Mozilla Firefox builds has been discontinued, and only the GeckoDriver implementation can be used today. Testers are therefore required to use GeckoDriver to run automated tests on Mozilla Firefox version 47.0 and above.
The major advantage of using GeckoDriver over the legacy Firefox driver is compatibility. GeckoDriver relies on the W3C WebDriver protocol to communicate with Selenium. W3C is a universally defined standard for WebDriver. This means Selenium developers do not need to create a new driver version for each browser release. The same WebDriver implementation can be used across multiple browser versions, which is why GeckoDriver is preferred over the older Firefox driver.
How to Download and Install GeckoDriver in Selenium
GeckoDriver is distributed as an executable file that can be downloaded directly onto your system. Follow the steps below to download and install GeckoDriver for Selenium automation.
Step 1) Select the appropriate version.
On the official releases page https://github.com/mozilla/geckodriver/releases, choose the appropriate GeckoDriver build that matches your operating system and architecture.
Step 2) Extract the ZIP file.
Once the ZIP file download is complete, extract its contents into a folder on your machine.
Step 3) Note the driver location.
Record the folder path where you extracted the driver. This location will be used later to instantiate the driver from your test script.
Ways to Initialize GeckoDriver
There are three different ways to initialize GeckoDriver in your Selenium test scripts. Choose the one that best fits your test framework and Selenium version.
1. Using DesiredCapabilities
First, set the system property for GeckoDriver.
Syntax:
System.setProperty("webdriver.gecko.driver","Path to geckodriver.exe file");
Example:
System.setProperty("webdriver.gecko.driver","D:\\Downloads\\GeckoDriver.exe");
Next, set Desired Capabilities. Desired Capabilities help Selenium understand the browser name, version, and operating system required to execute the automated tests. Below is the code to configure GeckoDriver using the DesiredCapabilities class.
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
Here is the complete code:
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
driver = new FirefoxDriver(capabilities);
2. Using Marionette Property
GeckoDriver can also be initialized using the marionette property as shown below.
System.setProperty("webdriver.gecko.driver","D:\\Downloads\\GeckoDriver.exe");
If GeckoDriver is initialized using the above method, the Desired Capabilities code is not required.
3. Using FirefoxOptions
Mozilla Firefox version 47+ exposes the Marionette driver as a legacy system. Taking advantage of this, the Marionette driver can be invoked through Firefox Options as shown below.
FirefoxOptions options = new FirefoxOptions();
options.setLegacy(true);
Code for Launching Firefox Using GeckoDriver
The following JUnit-based example shows a complete, runnable Selenium test that launches Firefox through GeckoDriver and navigates to a demo URL.
package com.guru99.demo;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class GeckoDriverDemo {
String driverPath = "D:\\Guru99Demo\\GeckoDriver.exe";
public WebDriver driver;
@Before
public void startBrowser() {
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
}
@Test
public void navigateToUrl() {
driver.get("https://demo.guru99.com/selenium/guru99home/");
}
@After
public void endTest() {
driver.quit();
}
}
Code Explanation
@Before method
Initially, we set the system property for GeckoDriver to the geckodriver.exe download location. We also set the marionette property to true so Selenium uses the Marionette protocol to communicate with GeckoDriver. Finally, we start the Firefox browser instance using the Desired Capabilities object.
The following statements achieve this setup.
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
driver = new FirefoxDriver(capabilities);
@Test method
We navigate to the user-specified URL using the built-in get method provided by Selenium WebDriver, as shown below.
driver.get("https://demo.guru99.com/selenium/guru99home/");
@After method
Finally, we close the browser instance using the quit method.
driver.quit();
Modify a Script for Non-Gecko to Gecko
Non-GeckoDriver scripts used before Selenium 3 were straightforward. You simply created an instance of the Firefox driver and used the instance variable.
@Before
public void startBrowser() {
driver = new FirefoxDriver();
}
To convert the script for GeckoDriver, you only need to add one line of code that points to the geckodriver.exe location.
@Before
public void startBrowser() {
System.setProperty("webdriver.gecko.driver", "D:\\Downloads\\GeckoDriver.exe");
driver = new FirefoxDriver();
}
Common Exceptions Occurred While Using GeckoDriver
The following is a list of common exceptions that occur while using GeckoDriver, along with their resolutions.



