0

While running selenium test in eclipse I am getting below error message

"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:754) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:40) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:114) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:150) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98) at AutomationFramework.FirstTestcase.main(FirstTestcase.java:9)

Can anyone suggest me how to fix it?

Shoaib Akhtar
  • 1,393
  • 5
  • 17
  • 46
Akhil
  • 11
  • 1
  • 8
  • add the proper library for that in eclipse – BHAVIK Nov 01 '17 at 05:41
  • share your code also – Shoaib Akhtar Nov 01 '17 at 05:46
  • This is the code i used; public class FirstTestcase { public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub WebDriver driver = new FirefoxDriver(); //Launch the Online Store Web site driver.get("http://www.store.demoqa.com"); // Print a Log In message to the screen System.out.println("Successfully opened the website www.Store.Demoqa.com"); //Wait for 5 Second //Thread.sleep(5000); // Close the driver driver.quit(); } } " – Akhil Nov 01 '17 at 05:52
  • hi bhavik , Can you give me details – Akhil Nov 01 '17 at 05:59

1 Answers1

0

Your code will work for old version of Selenium. After Selenium 3 you need to use gecko driver to work with Firefox. Download gecko driver and add below line in your code.

System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe");//give location accordingly for your gecko driver
WebDriver driver = new FirefoxDriver();

For more info go through this post

Shoaib Akhtar
  • 1,393
  • 5
  • 17
  • 46