Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I am now learning Selenium and have met a problem.

I am aware that Selenium supported the 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 the 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  it 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 what is the difference between webdriver.gecko.driver and webdriver.firefox.marionette or wires.exeand geckodriver.exe?

1 Answer

0 votes
by (62.9k points)

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 included with Firefox.

This driver has its 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//

Browse Categories

...