Executing Selenium WebDriver Script with Chrome Driver

In this tutorial, we will cover how to execute Selenium scripts on Google Chrome browser. Unlike Mozilla Firefox Driver, Selenium does not have an inbuilt support of chrome browser. To initialize chrome browser an executable file named chromedriver.exe is required.

Environment Setup for Chrome Browser:

Visit the link Chrome Driver Executable

To download chrome driver executable, visit third party section of download section seleniumhq.org website. Refer screenshots for ease:

Download Chrome Driver


Download the latest version of chrome driver executable (at the time this article is written its 2.22).

Let us use this executable in our code:

To invoke chrome browser:

  1. Create an instance of ChromeDriver class.
  2. Set the system property of the variable “webdriver.chrome.drive” and update the value with the path of chromedriver executable file.
  3. Initialize the ChromeDriver class.
setProperty(“key”, “value”) method is used in Java to set the property (value of the system variable), it accepts two string arguments i.e. variable name (here, its “webdriver.chrome.driver”) and its value (the location where driver.exe is placed). Give exact driver name and full driver location.

Points to Remember: If we don’t set the path / or if we give the wrong path, then you will be seeing below error immediately once you start your script.

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

Now we are good to start working with chrome driver. All other basic APIs will remains same in the case of Chrome browser also. For API walkthrough read Working with FirefoxDriver.

In the next tutorial, we will cover How to execute selenium scripts with Internet Explorer and what are challenges faced with Internet Explorer.

PS: For any questions, queries or feedback. Feel free to write us at amrita@qatechhub.com or support@qatechhub.com Happy learning 🙂

Amrita Joshi

About the Author

Amrita Joshi