Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 273
LU Cai Avatar asked Apr 07 '17 08:04

LU Cai


People also ask

What is marionette Selenium?

Marionette is similar to Selenium as it uses a lot of the same structure and API as the latter. However, it does include certain commands to interact with Gecko's chrome interface. The point of using Marionette is to act as Selenium does for web content – enabling the tester to remotely control a user agent.

How do I disable marionette in Firefox?

turning off marionette : Turning off marionette is no more a solution while we work with Selenium 3. x and recent Mozilla Firefox Browser releases. By forcefully setting "marionette" to false through DesiredCapabilities class you won't be able to open Mozilla Firefox Browser above version 48.

Why is the the Gecko driver used instead of the Firefox while we run our test in Mozilla?

Why GeckoDriver is used? After version 47, Mozilla Firefox came out with Marionette, which is an automation driver. It remotely controls either the UI or the internal JavaScript of a Gecko platform, such as Firefox. Hence, we require GeckoDriver for Firefox.

What does WebDriver driver new FirefoxDriver () mean?

WebDriver is an interface that is available in Selenium jar files. driver is webDriver reference variable. New is a keyword, we use to create an instance of the class. And, FireFoxDriver() is a class already existing in Selenium. So, you can import it and start using it for your test.


1 Answers

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 
like image 71
Florent B. Avatar answered Sep 28 '22 07:09

Florent B.