Documente Academic
Documente Profesional
Documente Cultură
(https://www.guru99.com/)
Before Selenium 3, Mozilla Firefox browser was the default browser for Selenium. After
Selenium 3, testers need to initialize the script to use Firefox using GeckoDriver explicitly.
Selenium uses W3C Webdriver protocol to send requests to GeckoDriver, which translates
them into a protocol named Marionette. Firefox will understand the commands transmitted in
the form of Marionette protocol and executes them.
(/images/1/030118_0746_GeckoMarion11.png)
The major advantage of using GeckoDriver as opposed to the default Firefox driver is
Compatibility. GeckoDriver uses W3C WebDriver protocol to communicate with Selenium.
W3C is a universally defined standard for Web Driver. This means Selenium Developers
(People who code Selenium base) need not create a new version of Web Driver for each
browser version. The same Web Driver can be used for multiple browser versions. Hence,
GeckoDriver is preferred compared to the earlier implementation of Firefox driver.
https://www.guru99.com/gecko-marionette-driver-selenium.html 1/9
12/13/2018 Gecko (Marionette) Driver Selenium: Download, Install, Use with Firefox
Download and Install Gecko Driver:
Gecko Driver is available as an executable file that can be downloaded on the system. The
following are the list of steps to download gecko driver.
(/images/1/030118_0746_GeckoMarion1.png)
Step 2) Once the ZIP file download is complete, extract the contents of ZIP File onto a file
folder
(/images/1/030118_0746_GeckoMarion2.png)
Step 3) Note the location where you extracted the driver. Location will be used later to
instantiate the driver.
(/images/1/030118_0746_GeckoMarion3.png)
https://www.guru99.com/gecko-marionette-driver-selenium.html 2/9
12/13/2018 Gecko (Marionette) Driver Selenium: Download, Install, Use with Firefox
Ways to ini alize GeckoDriver:
There are three different ways to initialize GeckoDriver.
1. Using DesiredCapabilities:
Syntax:
Example:
System.setProperty("webdriver.gecko.driver","D:\\Downloads\\GeckoDriver.exe");
Desired Capabilities help Selenium to understand the browser name, version and operating
system to execute the automated tests. Below is the code to set gecko driver using
DesiredCapabilities class.
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
driver= new FirefoxDriver(capabilities);
System.setProperty("webdriver.firefox.marionette","D:\\Downloads\\GeckoDriver.exe");
If gecko driver is initialized using the above method, code for desired capabilities is not
required.
3. Using FirefoxOptions:
https://www.guru99.com/gecko-marionette-driver-selenium.html 3/9
Mozilla
12/13/2018 Firefox version 47+ has marionette
Gecko driver
(Marionette) Driver as aDownload,
Selenium: legacyInstall,
system. Taking
Use with Firefox advantage of
package com.guru99.demo;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
@Before
public void startBrowser() {
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver(capabilities);
@Test
public void navigateToUrl() {
driver.get("http://demo.guru99.com/selenium/guru99home/");
}
@After
public void endTest() {
driver.quit();
}
Code Explanation:
@Before method:
https://www.guru99.com/gecko-marionette-driver-selenium.html 4/9
Initially,
12/13/2018we need to set the system propertyDriver
Gecko (Marionette) for Selenium:
gecko Download,
driver to theUse
Install, geckdriver.exe
with Firefox file
download location. We need to set the marionette property to true for Selenium to use
Marionette protocol to communicate with Gecko Driver. Finally, we need to start the Firefox
browser instance using the object for Desired Capabilities.
System.setProperty("webdriver.gecko.driver", driverPath);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette",true);
driver= new FirefoxDriver(capabilities);
@Test method:
We are navigating to user-specified URL using the inbuilt "get" method provided by
Selenium web driver. The below statement help to achieve the same.
driver.get("http://demo.guru99.com/selenium/guru99home/");
@After method:
Finally, we are closing the browser instance using the quit method.
driver.quit();
@Before
public void startBrowser() {
driver = new FirefoxDriver();
https://www.guru99.com/gecko-marionette-driver-selenium.html 5/9
12/13/2018 Gecko (Marionette) Driver Selenium: Download, Install, Use with Firefox
@Before
public void startBrowser() {
System.setProperty("webdriver.firefox.marionette", "D:\\Downloads\\GeckoDriver.ex
e");
driver = new FirefoxDriver();
This exception occurs when user tries to instantiate Firefox driver without setting the system
property for gecko driver. This is usually done by beginners to Selenium who are not aware
of the changes made from Selenium 3 to Selenium previous versions.
The resolution for the above exception is to set the system property for gecko driver with the
location of geckodriver.exe file as below
System.setProperty("webdriver.gecko.driver", "D:\\Downloads\\geckodriver.exe");
Please note that you need to set the property of gecko driver before creating an instance of
Mozilla Firefox driver.
This exception usually occurs when Firefox version has been upgraded to the latest version.
The resolution for this exception is to update the selenium jar file and gecko driver to the
latest version and use the same.
https://www.guru99.com/gecko-marionette-driver-selenium.html 6/9
This exception
12/13/2018 occurs due to compatibility
Gecko (Marionette) issues between
Driver Selenium: Selenium
Download, and
Install, Use with Gecko driver.
Firefox
Gecko driver works with Firefox version 47 or above. It can be resolved by updating Firefox
version to 47 or above.
This exception is the message generated when web driver is unable to establish a
connection with Firefox. It can be resolved using any one of the following techniques.
selenium.html)
Selenium Tutorials
42) SSL Certificate Error Handling (/ssl-certificate-error-handling-selenium.html)
(https://www.facebook.com/guru99com/)
https://www.guru99.com/gecko-marionette-driver-selenium.html 8/9
12/13/2018
Gecko (Marionette) Driver Selenium: Download, Install, Use with Firefox
(https://twitter.com/guru99com)
(https://www.youtube.com/channel/UC19i1XD6k88KqHlET8atqFQ)
(https://forms.aweber.com/form/46/724807646.htm)
About
About US (/about-us.html)
Advertise with Us (/advertise-us.html)
Write For Us (/become-an-instructor.html)
Contact US (/contact-us.html)
Career Sugges on
SAP Career Suggestion Tool (/best-sap-module.html)
Software Testing as a Career (/software-testing-career-
complete-guide.html)
Certificates (/certificate-it-professional.html)
Interes ng
Books to Read! (/books.html)
Suggest a Tutorial
Blog (/blog/)
Quiz (/tests.html)
Review (/best-ergonomic-mouse.html)
Execute online
Execute Java Online (/try-java-editor.html)
Execute Javascript (/execute-javascript-online.html)
Execute HTML (/execute-html-online.html)
Execute Python (/execute-python-online.html)
https://www.guru99.com/gecko-marionette-driver-selenium.html 9/9