Difference between webdriver.firefox.marionette & webdriver.gecko.driver

44,882

Solution 1

Up to version 45 (pushed to version 47), the driver used to automate Firefox was an extension included with each client. But this extension was dropped, probably due to the change of policy which now requires all the extensions to be signed by Mozilla.

Marionette is the new driver that is shipped/included with Firefox. This driver has it's own protocol which is not directly compatible with the Selenium/WebDriver protocol.

The Gecko driver (previously named wires) is an application server implementing the Selenium/WebDriver protocol. It translates the Selenium commands and forwards them to the Marionette driver.

For the Java client, the default behavior is to use the Gecko driver, but it can be overridden to use the legacy extension as a driver with the webdriver.firefox.marionette property:

System.setProperty("webdriver.firefox.marionette", "false");

or with the marionette capability through FirefoxOptions :

FirefoxOptions options = new FirefoxOptions()
  .setLegacy(true);

WebDriver driver = new FirefoxDriver(options);
// or with a remote server
WebDriver driver = new RemoteWebDriver(remoteUrl, options.toDesiredCapabilities());

or directly with the DesiredCapabilities:

DesiredCapabilities capa = DesiredCapabilities.firefox();
capa.setCapability("marionette", false);

WebDriver driver = new FirefoxDriver(capa);
// or with a remote server
WebDriver driver = new RemoteWebDriver(remoteUrl, capa);

And to define the location of the Gecko driver, either place the driver in a folder present in the PATH environment variable, or define the location in the property webdriver.gecko.driver:

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

or launch a remote server with the property assigned in the command line:

java -Dwebdriver.gecko.driver="C:\\geckodriver.exe" -jar selenium-server-standalone-3.4.0.jar

Solution 2

Till Firefox 47.x releases the legacy driver was implemented as a Firefox extension. This extension was installed in the profile used by the driver whenever WebDriver launched Firefox.

Hence we we used:

WebDriver driver =  new FirefoxDriver();
driver.navigate().to("https://gmail.com");

Firefox 48 disabled the browser extension and introduced WebDriver. Since then GeckoDriver the Marionette-based solution, being developed and maintained by Mozilla is for use automating Mozilla Firefox Browser.

Marionette

According to Mozilla's Official Documentation on developer.mozilla.org. Marionette is the Automation Driver. It uses the remote protocol of Firefox which can control the UI. Marionette accepts requests and executes them in Gecko. It also have a client. The client sends instructions to the server and the server executes the instructions within the browser.

Hence we started using Marionette:

System.setProperty("webdriver.firefox.marionette","C:\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://gmail.com");

Wires

There are some references to rename the executable file to ‘wires.exe’ and add it to your path. Hence the following was used:

System.setProperty("webdriver.firefox.marionette","C:\\wires.exe");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("https://gmail.com");

GeckoDriver

GeckoDriver is the executable file that we need to download within our system and mention its location in our scripts/programs while executing our testcases. GeckoDriver in turn will start the Mozilla Firefox Browser.

These excerpts have been taken out of Jim Evan's epic answer to the question What are the benefits of using Marionette FirefoxDriver instead of the old Selenium FirefoxDriver for a Selenium tester? which provides us a detailed understanding of how GeckoDriver and Marionette came into practice.

Hence we started using geckodriver.exe:

System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
WebDriver driver =  new FirefoxDriver();
driver.navigate().to("https://gmail.com");

Now in current scenario you still have the option to execute your Automation through legacy Firefox 47.x browser and recent Firefox 53.x browser releases as well.

Usecase 1:

In case of using the legacy Firefox 47.x browsers you have to explicitly set "marionette" to false through DesiredCapabilities class as follows:

DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("firefox_binary", "C:\\Program Files\\Mozilla Firefox47\\firefox.exe");
dc.setCapability("marionette", false);
WebDriver driver =  new FirefoxDriver(dc);
driver.navigate().to("https://gmail.com");

Usecase 2:

In case of using the legacy Firefox 47.x browsers, if you skip setting "marionette" to false or if you set "marionette" to true, you will observe a IllegalStateException

Usecase 3:

In case of using the Firefox 53.x browsers you can choose to skip setting "marionette" to true as follows which will show the Marionette INFO logs e.g. Marionette INFO Listening on port 11105 :

System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
WebDriver driver =  new FirefoxDriver();
driver.navigate().to("https://gmail.com");

Usecase 4:

In case of using the Firefox 53.x browsers you can explicitly set "marionette" to true through DesiredCapabilities class which will show the Marionette WARN logs as well e.g. WARN TLS certificate errors will be ignored for this session

System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
WebDriver driver =  new FirefoxDriver(dc);
driver.navigate().to("https://gmail.com");

Usecase 5:

In case of using the Firefox 53.x browsers if you forcefully set "marionette" to false through DesiredCapabilities class you will observe a UnreachableBrowserException.

Solution 3

Marionette is the new driver that is shipped/included with the latest Firefox versions.

However, Geckodriver is a Proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers. Geckodriver provides HTTP API described by the WebDriver protocol to communicate with Gecko browsers, such as Firefox version above 47.

System.setProperty("webdriver.gecko.driver","path of/geckodriver.exe");
WebDriver driver = new FirefoxDriver();

If still you are getting issues (due to incompatibility of FF versions) you can use the following capabilities:

DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
Share:
44,882
LU Cai
Author by

LU Cai

Updated on January 24, 2020

Comments

  • LU Cai
    LU Cai over 4 years

    I am now learning Selenium and have met a problem.

    I am aware that Selenium supported old Firefox version by default without a driver. And for recent versions of Firefox, we have to download the driver and define it using System.setProperty.

    According to this link, for Firefox 45 and 46, start driver code could look like this:

    WebDriver driver = new FirefoxDriver();
    

    My Firefox is version 45.5.1., but above code still won't work. So according to this link, I have added:

    System.setProperty("webdriver.firefox.marionette","C:\\geckodriver.exe");

    And it worked.

    Then I realized that I haven't installed geckodriver.exe on my computer. To see how it goes, I have changed to the code below:

    System.setProperty("webdriver.firefox.marionette","");
    

    It still works.

    So, here comes my first problem: What happened? I am sure that no geckodriver.exe exists in my environment. If no location has been pointed, then why should I have to set property?

    Also, I have seen code like:

    System.setProperty("webdriver.gecko.driver", "/tools/marionette/wires.exe");
    

    My second question is that what is the difference between webdriver.gecko.driver and webdriver.firefox.marionette or wires.exeand geckodriver.exe?

  • Peter M. - stands for Monica
    Peter M. - stands for Monica almost 7 years
    Thank you so much! I found so many articles saying that setting marionette to "true" or "false" fixed it. This is the first article explaining why, and not just a blind cargo-cult programming solution.
  • Peter M. - stands for Monica
    Peter M. - stands for Monica almost 7 years
    "Gecko driver (previously named wires)" - thanks for that. It explains some of misunderstandings.
  • Thomas Lee
    Thomas Lee over 6 years
    So marionette driver is to support the feature that not available in geckodriver ?
  • oldboy
    oldboy almost 6 years
    i can't seem to find the official download page of the geckodriver. do you have the link stored somewhere??