Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 290
Shahzad Masood Avatar asked Aug 10 '16 12:08

Shahzad Masood


People also ask

What is system setProperty in Selenium?

setProperty(“propertyName”, “value”)” . It implies that it sets the system property 'propertyName' to have the value 'value'. While testing with Selenium, you will make use of the setProperty method because the browser doesn't have a built-in server to run the automation code.

What is Gecko driver in Selenium?

GeckoDriver is a web browser engine which is used in many applications developed by Mozilla Foundation and the Mozilla Corporation. GeckoDriver is the link between your tests in Selenium and the Firefox browser. GeckoDriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers.

How does system setProperty work?

setProperty manages the initialization of the Chrome driver in the first step. The System. setProperty() method forms the basis for test case automation on any browser. Naturally, QAs must understand how to use this fundamental method for all automation purposes in Selenium.


1 Answers

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!

like image 88
Kashif Siraj Avatar answered Nov 15 '22 09:11

Kashif Siraj