By Reema


2016-07-30 17:38:13 8 Comments

I am trying to launch Mozilla but still I am getting this error:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

I am using Selenium 3.0.01 Beta version and Mozilla 45. I have tried with Mozilla 47 too. but still the same thing.

4 comments

@chuha.billi 2017-11-08 10:59:02

Every Driver service in selenium calls the similar code(following is the firefox specific code) while creating the driver object

 @Override
 protected File findDefaultExecutable() {
      return findExecutable(
        "geckodriver", GECKO_DRIVER_EXE_PROPERTY,
        "https://github.com/mozilla/geckodriver",
        "https://github.com/mozilla/geckodriver/releases");
    }

now for the driver that you want to use, you have to set the system property with the value of path to the driver executable.

for firefox GECKO_DRIVER_EXE_PROPERTY = "webdriver.gecko.driver" and this can be set before creating the driver object as below

System.setProperty("webdriver.gecko.driver", "./libs/geckodriver.exe");
WebDriver driver = new FirefoxDriver();

@Ripon Al Wasim 2017-05-13 08:00:40

Selenium WebDriver Java code:

Download Gecko Driver from https://github.com/mozilla/geckodriver/releases based on your platform. Extract it in a location by your choice. Write the following code:

System.setProperty("webdriver.gecko.driver", "D:/geckodriver-v0.16.1-win64/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.lynda.com/Selenium-tutorials/Mastering-Selenium-Testing-Tools/521207-2.html");

@Ripon Al Wasim 2017-05-13 08:01:50

Location may vary individual to individual. I extracted it on D drive

@Kanth25 2016-10-14 17:12:00

  1. Download gecko driver from the seleniumhq website (Now it is on GitHub and you can download it from Here) .
    1. You will have a zip (or tar.gz) so extract it.
    2. After extraction you will have geckodriver.exe file (appropriate executable in linux).
    3. Create Folder in C: named SeleniumGecko (Or appropriate)
    4. Copy and Paste geckodriver.exe to SeleniumGecko
    5. Set the path for gecko driver as below

.

System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.10.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();

@Saurabh Gaur 2016-07-30 17:53:02

The Selenium client bindings will try to locate the geckodriver executable from the system PATH. You will need to add the directory containing the executable to the system path.

  • On Unix systems you can do the following to append it to your system’s search path, if you’re using a bash-compatible shell:

    export PATH=$PATH:/path/to/geckodriver
    
  • On Windows you need to update the Path system variable to add the full directory path to the executable. The principle is the same as on Unix.

All below configuration for launching latest firefox using any programming language binding is applicable for Selenium2 to enable Marionette explicitly. With Selenium 3.0 and later, you shouldn't need to do anything to use Marionette, as it's enabled by default.

To use Marionette in your tests you will need to update your desired capabilities to use it.

Java :

As exception is clearly saying you need to download latest geckodriver.exe from here and set downloaded geckodriver.exe path where it's exists in your computer as system property with with variable webdriver.gecko.driver before initiating marionette driver and launching firefox as below :-

//if you didn't update the Path system variable to add the full directory path to the executable as above mentioned then doing this directly through code
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");

//Now you can Initialize marionette driver to launch firefox
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(capabilities); 

And for Selenium3 use as :-

WebDriver driver = new FirefoxDriver();

If you're still in trouble follow this link as well which would help you to solving your problem

.NET :

var driver = new FirefoxDriver(new FirefoxOptions());

Python :

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.FIREFOX

# Tell the Python bindings to use Marionette.
# This will not be necessary in the future,
# when Selenium will auto-detect what remote end
# it is talking to.
caps["marionette"] = True

# Path to Firefox DevEdition or Nightly.
# Firefox 47 (stable) is currently not supported,
# and may give you a suboptimal experience.
#
# On Mac OS you must point to the binary executable
# inside the application package, such as
# /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin
caps["binary"] = "/usr/bin/firefox"

driver = webdriver.Firefox(capabilities=caps)

Ruby :

# Selenium 3 uses Marionette by default when firefox is specified
# Set Marionette in Selenium 2 by directly passing marionette: true
# You might need to specify an alternate path for the desired version of Firefox

Selenium::WebDriver::Firefox::Binary.path = "/path/to/firefox"
driver = Selenium::WebDriver.for :firefox, marionette: true

JavaScript (Node.js) :

const webdriver = require('selenium-webdriver');
const Capabilities = require('selenium-webdriver/lib/capabilities').Capabilities;

var capabilities = Capabilities.firefox();

// Tell the Node.js bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.set('marionette', true);

var driver = new webdriver.Builder().withCapabilities(capabilities).build();

Using RemoteWebDriver

If you want to use RemoteWebDriver in any language, this will allow you to use Marionette in Selenium Grid.

Python:

caps = DesiredCapabilities.FIREFOX

# Tell the Python bindings to use Marionette.
# This will not be necessary in the future,
# when Selenium will auto-detect what remote end
# it is talking to.
caps["marionette"] = True

driver = webdriver.Firefox(capabilities=caps)

Ruby :

# Selenium 3 uses Marionette by default when firefox is specified
# Set Marionette in Selenium 2 by using the Capabilities class
# You might need to specify an alternate path for the desired version of Firefox

caps = Selenium::WebDriver::Remote::Capabilities.firefox marionette: true, firefox_binary: "/path/to/firefox"
driver = Selenium::WebDriver.for :remote, desired_capabilities: caps

Java :

DesiredCapabilities capabilities = DesiredCapabilities.firefox();

// Tell the Java bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.setCapability("marionette", true);

WebDriver driver = new RemoteWebDriver(capabilities); 

.NET

DesiredCapabilities capabilities = DesiredCapabilities.Firefox();

// Tell the .NET bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.SetCapability("marionette", true);

var driver = new RemoteWebDriver(capabilities); 

Note : Just like the other drivers available to Selenium from other browser vendors, Mozilla has released now an executable that will run alongside the browser. Follow this for more details.

You can download latest geckodriver executable to support latest firefox from here

@Reema 2016-07-30 23:12:05

Thanks you so much. This works just perfect. But just for information, what is this geckodriver all about? I have been working with selenium for quite sometime and i didn't come across this before. But now i had just recently change my machine and got this error.

@Saurabh Gaur 2016-07-31 00:52:20

@Reema Just like the other drivers available to Selenium from other browser vendors, Mozilla has released now an executable that will run alongside the browser. Have alook for more details..developer.mozilla.org/en-US/docs/Mozilla/QA/Marione‌​tte/…

@Michal 2016-08-13 13:04:13

How to set path for geckodriver for all platforms? My Java app is built across different systems.

@Saurabh Gaur 2016-08-13 14:38:51

@Michal You need to set geckodriver location to your system PATH variable which valid for all platform...what is you OS??

@Thariq Nugrohotomo 2016-08-15 09:49:41

I decided to find another library that rarely make breaking changes like this. Seriously, after I updated the firefox or library, usually it will not works anymore. Even worse, the latest geckodriver.exe for windows only available for 64-bit system. It's time to say good bye to Selenium.

@Saurabh Gaur 2016-08-15 15:47:56

@ThariqNugrohotomo Why is not works.. could you explain more??? Haw did you tried??

@8protons 2016-08-31 20:17:19

I'm really confused. "The Selenium client bindings will try to locate the geckodriver" Is WebDriver turning into Geckdriver? What's going on here?

@Saurabh Gaur 2016-08-31 23:00:43

@8protons Have a look here developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/… geckodriver provides by Mozilla, .. geckodriver implements WebDriver So selenium clients bindings try to locate geckodriver to support automation on latest firefox

@swathi 2016-10-14 01:39:15

Its not working for me.I am using .net I added the directory of the driver in the path but still the same issue.I migrated to selenium 3.0.Is there anything else I need to update?

@Saurabh Gaur 2016-10-14 03:05:29

@swathi Could you share how did you add the directory of the the path??

@swathi 2016-10-14 03:11:45

@SaurabhGaur able to solve it by getting the v0.11.1 version of gecko driver.. thank you :)

@Surabhil Sergy 2016-10-17 11:10:27

@SaurabhGaur Can you suggest the python alternative in this case to set a default download location. profile = webdriver.firefox.firefox_profile.FirefoxProfile() profile.set_preference('browser.download.dir','D:\Downloads'‌​) driver = webdriver.Firefox(firefox_profile=profile)

@Saurabh Gaur 2016-10-17 13:16:48

@SurabhilSergy Have a look here

@Surabhil Sergy 2016-10-17 13:46:29

@SaurabhGaur Thanks. I have seen this already. I was looking the marionette driver way for that? Similar question - looking for pythonic way

@Thufir 2017-07-09 22:29:59

where is the official documentation on this gecko thing and selenium?

@Saurabh Gaur 2017-07-10 11:17:17

@Thufir have a look here..

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] How can i start the constructor from my class?

2 Answered Questions

1 Answered Questions

2 Answered Questions

Error when trying to execute a code?

  • 2017-10-06 19:06:56
  • Nayan
  • 102 View
  • -3 Score
  • 2 Answer
  • Tags:   java selenium

3 Answered Questions

[SOLVED] Error with selenium webdriver code( geckodriver)

  • 2016-12-27 17:01:43
  • ayav
  • 2154 View
  • 1 Score
  • 3 Answer
  • Tags:   selenium

1 Answered Questions

I see an error while running a package in Eclipse

0 Answered Questions

Exception in thread "main" java.lang.IllegalStateException for using Selenium

  • 2016-09-20 21:24:35
  • evabb
  • 1414 View
  • 1 Score
  • 0 Answer
  • Tags:   java selenium bots

5 Answered Questions

[SOLVED] How to use geckodriver in selenium webdriver 3.0 beta?

Sponsored Content