webdrivermanager icon indicating copy to clipboard operation
webdrivermanager copied to clipboard

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property

Open ShruthiBalaji opened this issue 8 years ago • 6 comments

Hello All,

I have set up all the required jar files and chrome location set up but still getting the error ....I am a beginner, please help me solve this issue .

PFB the error code,

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:847) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:125) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:156) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:346) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:91) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Check.basic.main(basic.java:15)

PFB the simple program:

package Check;

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;

public class basic {

public static void main(String[] args) throws Exception {

    //Here we are specifing driver type and its location
	//System.setProperty("webdriver.Chrome.driver", "C:/Program Files/Selenium/chromedriver_win32/chromedriver.exe");
	System.setProperty("webdriver.Chrome.driver","C:\\Program Files\\Selenium\\chromedriver.exe");
	
	// Here we are creating object of web driver
	WebDriver driver = new ChromeDriver();
	
	// we are navifating to google.com with the help og get menthod
	driver.get("https://google.com");
	
	// Here are maximinzing our window
	driver.manage().window().maximize();
	
	//Sleep
	Thread.sleep(3000);
	
	//close
	driver.close();
	
	
}

}

Kindly assist me.

ShruthiBalaji avatar Aug 04 '18 08:08 ShruthiBalaji

Call to WebDriverManager.chromedriver().setup(); before the WebDriver instantiation.

bonigarcia avatar Aug 16 '18 07:08 bonigarcia

package Examples;

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;

public class Sample {

public static void main(String[] args) throws InterruptedException {
	// TODO Auto-generated method stub
	WebDriver driver= new ChromeDriver();
	/*System.setProperty("webdriver.chrome.driver","D:\\installation\\chromedriver.exe" );
	driver.get("www.https://www.facebook.com/");*/
	System.out.println("welcome to facbook");
	Thread.sleep(2000);
	driver.quit();
	
}

} Error: Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:847) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Examples.Sample.main(Sample.java:10)

i hope all are seen my problem occurred in while running the program. please sort out my problem

harinarasing avatar Apr 09 '20 05:04 harinarasing

Try the below mention code @harinarasing and let me know if you have faced any issues

public static void main(String[] args) { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "D:\installation\chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.get("https://www.facebook.com"); }

gourab99 avatar Apr 19 '20 16:04 gourab99

I tried the same you said @gourab99 , I still get the same errors. Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Users\proy\Desktop\Selenium_Project at com.google.common.base.Preconditions.checkState(Preconditions.java:585) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:138) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:33) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:139) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:335) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at Test1.FirstSeleniumTest.main(FirstSeleniumTest.java:11)

paroqa02 avatar Sep 26 '20 18:09 paroqa02

I tried with the properties double slash, work fine. System.setProperty("webdriver.chrome.driver","C:\driver\chromedriver.exe");
driver = new ChromeDriver(); js = (JavascriptExecutor) driver; vars = new HashMap<String, Object>();

rubendelcastillo avatar Mar 10 '21 07:03 rubendelcastillo

how is it in linux?

corrreia avatar Jul 08 '21 22:07 corrreia