The path to the driver executable must be set by the webdriver.chrome.driver system property

Home/Selenium/The path to the driver executable must be set by the webdriver.chrome.driver system property

The path to the driver executable must be set by the webdriver.chrome.driver system property

Exception Driver Executable ChromeHave you experienced this Exception when starting your Selenium test for the first time with the Chrome WebDriver?

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 http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

The reason is probably that you have not told your system where to find your driver executable. Unlike when using the Firefox WebDriver you need to download a driver executable which is specifically for Chrome and builds the the conncection part between your Java Selenium program and the Chrome Webbrowser.

To fix this problem follow these steps:

  1. Download the latest ChromeDriver for your operating system here. If you work with windows choose “chromedriver_win32.zip”.
  2. Extract the content of the zip file (chromedriver.exe) to any place on your computer, that you will remember later.
  3. After replacing the location of the chromedriver.exe with the specific location on your computer, add the following code to your Selenium program before creating a new instance of ChromeDriver:
    System.setProperty("webdriver.chrome.driver","C:/Your/Path/to/chromedriver.exe");
    

That’s it. Problem should be solved. A whole working code sample could then look like this (again, first you need to edit the location of the chromedriver.exe):

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

/**
 * @author Nils Schuette via frontendtest.org
 */
public class ChromeDriverTest {

	/**
	 * @param args
	 * @throws InterruptedException
	 */
	public static void main(String
[] args) throws InterruptedException { // Telling the system where to find the chrome driver System.setProperty( "webdriver.chrome.driver", "C:/Your/Path/to/chromedriver.exe"); WebDriver webDriver = new ChromeDriver(); // Maximize the browser window webDriver.manage().window().maximize(); // Open google.com webDriver.navigate().to("http://www.google.com"); // Waiting a little bit before closing Thread.sleep(7000); // Closing the browser and webdriver webDriver.close(); webDriver.quit(); } }
By |August 24th, 2015|Selenium|9 Comments

9 Comments

  1. venkat February 10, 2016 at 7:50 am - Reply

    hi sir i’m trying but always error will coming above mention the error like that only
    plz give me solution

  2. Nils February 10, 2016 at 9:20 am - Reply

    Hey there, If you want, post a copy of your code an I will have a look at it.

  3. Raymond March 6, 2016 at 12:23 pm - Reply

    Why do we use “//” while entering the path of the Chrome driver or any other driver in the System.setproperty command..???
    Is there any specific reason for that..?

  4. Nils March 22, 2016 at 4:30 pm - Reply

    Hi Raymond, I am not totally sure what you mean. Im my example I am using “//” nowhere (but it would also work with //). Only if you use backslashes “\\” you actually must use them double because a single backslash tells java that the next character means “something special”. Two backslashes then are interpreted as a usual single one. Hope that helps.

  5. Manmit May 7, 2016 at 9:39 am - Reply

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

    public class Sample_Selenium {
    public static void main(String[] args) {
    System.setProperty(“webdriver.chrome.driver”,”/Users/manmitshelar/Documents/Selenium/chromedriver.exe”);
    WebDriver webDriver = new ChromeDriver();

    Error:
    Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist: /Users/Documents/Selenium/chromedriver.exe

  6. veera pulapakura February 10, 2017 at 5:46 pm - Reply

    package zooAdopTestsRepo;

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;

    public class AbstractPage {

    public WebDriver driver;

    public AbstractPage(WebDriver driver)
    {
    this.driver = driver;

    }
    public LandingPage navigatetoWebsite() throws InterruptedException
    {
    //public WebDriver driver = null;
    //System.setProperty(“webdriver.gecko.driver”, “C://geckodriver//geckodriver.exe”);

    //System.setProperty(“webdriver.gecko.driver”, “C://geckodriver//geckodriver.exe”);
    System.setProperty(“webdriver.chrome.driver”, “C:\\Program Files\\chromedriver_win32\\chromedriver.exe”);
    driver =new ChromeDriver();

    Thread.sleep(5000);
    String url = “http://www.thetestroom.com/webapp/index.html”;
    //driver.navigate().to(“http://www.thetestroom.com/webapp/index.html”);
    driver.get(“url”);
    return new LandingPage(driver);
    }

  7. veera pulapakura February 10, 2017 at 5:47 pm - Reply

    Hi above is my code , i am having the same error in my cucumber project

    —————————
    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
    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

  8. Bhavana May 4, 2017 at 10:06 pm - Reply

    any solution on this problem ?

  9. Swathy February 20, 2018 at 2:11 pm - Reply

    Hi I am facing the same issue and the path I have copied is correct please check the code and help me out :

    package com.First;

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.testng.annotations.Test;

    public class First_BrowserTest {
    @Test
    public void f() {

    System.setProperty(“chrome.driver.chrome”,”C:\\Users\\swathy.kothakota\\Desktop\\selenium\\chromedriver.exe”);
    WebDriver driver=new ChromeDriver();
    driver.get(“https://partnergw.antheminc.com/”);
    }
    }

    Error:

    [RemoteTestNG] detected TestNG version 6.13.1
    FAILED: f
    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:754)
    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:339)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
    at com.First.First_BrowserTest.f(First_BrowserTest.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
    at org.testng.TestNG.runSuites(TestNG.java:1028)
    at org.testng.TestNG.run(TestNG.java:996)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

    ===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
    ===============================================

    ===============================================
    Default suite
    Total tests run: 1, Failures: 1, Skips: 0
    ===============================================

Leave A Comment