0
votes

I am getting below exception when I am running a selenium browser initialization using java main method. The driver is available at the right path.

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:738) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:330) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:124) at invokebrowser.myfirsttestcase.initBroiwser(myfirsttestcase.java:23) at invokebrowser.myfirsttestcase.main(myfirsttestcase.java:16)

Code Snippet

System.setProperty("Webdriver.chrome.driver","C:\\Javalibs\\chromedriver.exe");
WebDriver driver = new ChromeDriver();//getting exception here
2
Please format your code - demouser123

2 Answers

0
votes

In the code, Webdriver.code.driver..., W is mentioned in capital letter. It has to be in small letter as shown in the error message.

System.setProperty("webdriver.chrome.driver","C:\\Javalibs\\chromedriver.exe"); 

Hope this helps you. Thanks.

0
votes

Here is the Answer to your Question:

While you work with Selenium 3.4.0, chromedriver 2.29 & Chrome 58.x you have to specify the absolute path of the chromedriver through System.setProperty

It's worth mentioning that the System Property is webdriver.chrome.driver

While you mention the absolute path of the chromedriver through System.setProperty, you have to either provide front slashes "/" or escape the back slashes "\\"

Your own code block will work for you with this simple twist:

    System.setProperty("webdriver.chrome.driver","C:\\Javalibs\\chromedriver.exe"); 
    WebDriver driver = new ChromeDriver();

OR

    System.setProperty("webdriver.chrome.driver","C:/Javalibs/chromedriver.exe"); 
    WebDriver driver = new ChromeDriver();

Let me know if this Answers your Question.