I am getting java.lang.IllegalStateException while using gecko driver. I have already installed latest version on both gecko and Firefox. Pleaseadvise

Answered

package automationFramework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirstTestCase
{
public static void main(String[] args) throws Exception
{
WebDriver driver = new FirefoxDriver();
driver.get(“http://store.demoqa.com/”);
System.setProperty(“webdriver.gecko.driver”,”C:\\\\Apeksha\\AP_Selenium_WebDriver\\Drivers.geckodriver.exe”);
System.out.println(“Successfully opened the website www.store.demoqa.com”);
Thread.sleep(5);
driver.quit();
}
}

 

Console :

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
at com.google.common.base.Preconditions.checkState(Preconditions.java:738)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:330)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
at automationFramework.FirstTestCase.main(FirstTestCase.java:10)

Add Comment
  • 4 Answer(s)
    Best answer

    This  is your coorect path:

    C:\\Apeksha\\AP_Selenium_WebDriver\\Drivers.geckodriver.exe.

    Train Answered on May 8, 2017.
    Add Comment

    I think you have mentioned wrong path for gecko driver executable file.

    Default Answered on May 3, 2017.
    Add Comment

    Path you have set is wrong

    Supporter Answered on May 5, 2017.
    Add Comment

    The call to create a FirefoxDriver instance should be done after establishing the system environment ‘ebdriver.gecko.driver’  and optionally other Firefx specific stuff.

    Train Answered on May 20, 2017.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.