0 votes
1 view
in DevOps and Agile by (19k points)

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$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:296)

    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)

    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)

1 Answer

0 votes
by (33.2k points)

When you use Selenium 3.x you should download chromedriver.exe and save it in your machine. Then you have to add the absolute path of the chromedriver.exe using System.setProperty.

Make sure while you mention the absolute path of the chromedriver.exe through System.setProperty, you should either provide front slashes "/" or escape the backslashes "\\".

For example:

public class first

{

    public static void main(String args[])

    {    System.setProperty("webdriver.chrome.driver","C:/your_directory/chromedriver.exe");

        WebDriver dr1= new ChromeDriver(); ;

        dr1.get("http://www.google.com/");

    }

}

Hope this answer helps you!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !

Categories

...