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
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
We use System.setProperty to provide the path of chromedriver/iedriver etc. Below is the declaration of java.lang.System.setProperty() method:
public static String setProperty(String key, String value)
key : Name of the system property
value: Value of the system property
e.g. System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.exe");
webdriver.chrome.driver : Chrome Driver (Name of system property) src/test/resources/chromedriver.exe : Path of chromedriver (value of system property)
Usually, we encounter IllegalArgumentException when key is empty.
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:-
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!
public class WaitTestCase { WebDriver driver;
}
Try below code in JAVA, and its working fine me
need to updated selenium and selenium drivers for java
updated firefox, firefox driver
in below code "C:\\Drivers\\geckodriver.exe" is path of your webdriver
Normally this happens when the FF version is above 45 and thats when we download gecko driver (https://github.com/mozilla/geckodriver/releases). After this unzip the contents of the folder and drag and drop the exe file of gecko driver to this folder (src/main/resources) if you have created a maven project.