In System.setProperty("webdriver.gecko.driver", "<Path to your WebDriver>"), what is meant by "Path to your WebDriver"?

Shahzad Masood picture Shahzad Masood · Aug 10, 2016 · Viewed 75.4k times · Source

I have this exception since I upgraded to 3.0 beta with Firefox.

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property

Answer

Kashif Siraj picture Kashif Siraj · Aug 14, 2016

It seems now we need to manually download and set path to the driver executable for Mozilla Firefox also just like chromedriver.

Following is what you need to do:-

  1. Go to http://docs.seleniumhq.org/download/
  2. Scroll down to "Third Party Drivers, Bindings, and Plugins" section on downloads page
  3. Click on Mozilla GeckoDriver and download(zip) latest version v0.10.0 for your operating system.
  4. Extract on your desired location i.e. c:\GeckoDriver\geckodriver.exe

Now you need to set system property and write following lines to initialize FireFoxDriver object:-

System.setProperty("webdriver.gecko.driver", "C:\GeckoDriver\geckodriver.exe");

WebDriver driver = new FirefoxDriver();

driver.get("http://seleniumhq.com");

Thats it!