Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property
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.
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.
Call to WebDriverManager.chromedriver().setup(); before the WebDriver instantiation.
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.
i hope all are seen my problem occurred in while running the program. please sort out my problem
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"); }
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.
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>();
how is it in linux?