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

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


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 serverWebDriver 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 serverWebDriver 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


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.


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);