Reputation: 31
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:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at practise_locators.DatePicker.main(DatePicker.java:11)
Here is my code:
package practise_locators;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class DatePicker {
public static void main(String[] args){
WebDriver driver = new ChromeDriver();
System.setProperty("WebDriver.Chrome.driver", "E:\\chromedriver.exe");
driver.get("https://www.google.com");
}
}
Upvotes: 2
Views: 31513
Reputation: 1
try to use WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver();
if the path is not working, please use latest selenium webdriver like 4.10 and use above code
Upvotes: 0
Reputation: 31
I was facing the same error when my code was like so:
System.setProperty("webdriver.chrome.driver","C:\\Users\\abs\\chromedriver_win32.exe");
It works after adding "chromedriver"
before ".exe"
like so:
System.setProperty("webdriver.chrome.driver","C:\\Users\\abs\\chromedriver_win32\\chromedriver.exe");
Upvotes: 0
Reputation: 11
Download the chromedriver version corresponding to the chrome version in your system from https://chromedriver.chromium.org/downloads . Unzip the file and run the below code in the IDE.
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;
public class Selintroduction {
public static void main(String[] args) {
//Invoking browser
System.setProperty("webdriver.chrome.driver","C:\\Users\\HP\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
}
}
(Path would depend on your file location in the PC.)
Upvotes: 1
Reputation: 1
I have seen many people are using wrong sequence. the sequence should be.
System.setProperty("webdriver.chrome.driver", "F:/chrome/chromedriver.exe"); WebDriver driver = new ChromeDriver();
driver.navigate().to("https://www.google.com");
Upvotes: 0
Reputation: 193088
The error says it all :
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:199)
The following phrases from the error implies that there is an error in the line containing webdriver.chrome.driver
The error can be either of the following :
Error in the System Class Method setProperty()
(including sequence) :
System.setProperty()
This line should be the very first line in your script.
Error in the specified Key :
"WebDriver.Chrome.driver"
Error in the Value field :
"E:\\chromedriver.exe"
You have to pass the absolute path of the WebDriver through either of the following options :
\\
) e.g. "C:\\path\\to\\chromedriver.exe"
/
) e.g. "C:/path/to/chromedriver.exe"
Your code seems to be having two issues as follows :
First issue is in specifying the Key which instead of "WebDriver.Chrome.driver"
should have been "webdriver.chrome.driver"
as follows :
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
Second issue is in the sequence of mentioning the Key "webDriver.chrome.driver"
in your program which should be before WebDriver driver = new ChromeDriver();
as follows :
System.setProperty("WebDriver.Chrome.driver", "E:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
Upvotes: 5