Marionette vs Geckodriver

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 when WebDriver launched Firefox.

Hece we we used:

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

Firefox 48 introduced two new features that disabled this browser extension. The first is the so-called “electrolysis” feature, or multiprocess Firefox. Electrolysis changes the way extensions have to deal with the browser. The second point was that all browser extensions must be signed by Mozilla before the browser allow them to load. This feature has been in Firefox for several versions, but beginning with Firefox 48, it can no longer be disabled.The WebDriver browser extension introduces several security concerns for the Firefox browser and thus will not be signed by Mozilla’s security team. Thus it turned out that the extension will be inoperable and Selenium can no longer communicate with Firefox. Since then the Marionette-based solution, being developed and maintained by Mozilla is for use in automating Firefox.

Marionette

Marionette is an automation driver for Mozilla’s Gecko engine. It is basically the the remote protocol of Gecko/Firefox. It can remotely control either the UI or the internal JavaScript of a Gecko platform, such as Firefox. Marionette consists of two parts: A server which takes requests and executes them in Gecko, and a client. The client sends commands to the server and the server executes the command inside the browser. Marionette combines a gecko component (the Marionette server) with an outside component (the Marionette client), which drives the tests. The Marionette server ships with Firefox, and to use it you will need to download a Marionette client.

Hence we started using Marionette:

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

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

With the release of Selenium 3 things changed. As Selenium 3 will not have any native implementation of Firefox, we have to direct all the driver commands through Gecko Driver. Gecko Driver is an executable file that you need to have in one of the system path before starting your tests. Firefox browser implements the WebDriver protocol using an executable called GeckoDriver.exe. This executable starts a server on your system. All your tests communicate to this server to run your tests. It translates calls into the Marionette automation protocol by acting as a proxy between the local and remote ends.

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, skipping to set “marionette” to false or setting “marionette” to true, you will observe a IllegalStateException

Usecase 3:

In case of using the Firefox 53.x browsers you can choose to skip to set “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.

Leave a Reply

%d bloggers like this: