Anushree P
Anushree P

Reputation: 31

The driver executable does not exist: C:\geckodriver.exe issue in Eclipse IDE

Please help me with this issue that is recurring every time I run my code. I have extracted Geckodriver files in C Drive but when I run my code, the error that comes up is 'Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\geckodriver.exe'.

My code is given below:

 package Basics;

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

public class Browserinvocation {
public static void main(String[] args) {
    // TODO Auto-generated method stub

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

WebDriver driver = new FirefoxDriver();//FirefoxDriver class is used to implement methods present in Webdriver-Invocation of browser
driver.get("https://www.amazon.in/");// Get method to hit the url in browser 

}

}

Error in console :

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\geckodriver.exe at com.google.common.base.Preconditions.checkState(Preconditions.java:534) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:136) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131) at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:98) at Basics.Browserinvocation.main(Browserinvocation.java:13)

Upvotes: 1

Views: 10043

Answers (5)

S K
S K

Reputation: 13

Above exception occurs whenever Precondition does not find path of relevant driver mentioned in System.setProperty() method by any reason like below:

  1. if path mentioned have different/wrong/single slashes.
  2. Driver file itself is not present at mentioned location.
  3. If path is mentioned in properties file or config file with double quotes.

Just check once before execution.

Upvotes: 1

Abu Dujana Mahalail
Abu Dujana Mahalail

Reputation: 1901

Just download geckodriver.exe and move it to drive C:

Upvotes: 0

sai varma
sai varma

Reputation: 1

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

Here remove . in between gecko and driver

Upvotes: 0

iamsankalp89
iamsankalp89

Reputation: 4739

Your code is running at my side, might be you are not extracting the gecko driver.

Change the path and try it once, it should worked

Please let me know selenium jars version and your firefox browser version

System.setProperty("webdriver.gecko.driver", "C:/Users/sankalp.gupta/Desktop/JAVASEL/geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("https://www.amazon.in");
System.out.println(driver.getCurrentUrl());
driver.close();

Upvotes: 0

unickq
unickq

Reputation: 3350

You should add the path to geckodriver.exe using / rather than \\. Change your line

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

to the following

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

Upvotes: 0

Related Questions