Exception in thread "main" java.lang.IllegalStateException:

298 views
Skip to first unread message

Sonu Sharma

unread,
Jul 4, 2018, 5:07:22 PM7/4/18
to Selenium Users
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:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:37)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:95)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:277)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:247)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:242)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:238)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at pack.New.main(New.java:13)


I'm running simple code in eclipse and getting above error

package pack;

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

public class New {

 public static void main(String[] args) {
  //set geckodriver path.
//System.setProperty("webdriver.gecko.driver","D:\\selenium\\geckodriver-v0.21.0-win64\\geckodriver.exe");
  //initialize firefox driver object to open firefox browser.
    WebDriver driver = new FirefoxDriver();
    //open URL in browser.
    driver.get("http://google.com/");
    String i = driver.getCurrentUrl();
    System.out.println(i);
    driver.close();
   }
}

Saravanan Jothimani

unread,
Jul 5, 2018, 12:27:51 AM7/5/18
to Selenium Users
Hi Sonu, 

System.setProperty  line is commented, please uncomment and execute. 

Thanks

Saravanan

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/774a7115-4f8c-4a66-b694-369beebb3288%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

total QA

unread,
Jul 6, 2018, 4:12:24 AM7/6/18
to Selenium Users
Also its always a good practice to copy this executable in the project location.In that case we dont need set any path as below

System.setProperty("webdriver.gecko.driver","geckodriver.exe");

To explore more topics on selenium refer to these postings:

Reply all
Reply to author
Forward
0 new messages