Executing Selenium WebDriver Script with Chrome Driver

July 22, 2016

Execute Selenium WebDriver Script with Chrome Browser:

In this tutorial, we will cover How to execute Selenium WebDriver on Google Chrome browser. Unlike Mozilla Firefox Driver, Selenium does not have an in-built support of Google Chrome Driver. To interact with Chrome Browser, Selenium requires a seperate Driver which is an executable file. Follow below steps to execute Selenium Scripts with Chrome Driver.

executing Selenium WebDriver scripts with chrome Driver

Environment Setup for Chrome Browser:

Visit the link Driver Download . Here we will find drivers to interact with all browsers.

To download Chrome Driver, visit Third party section of above link. Refer screenshots for ease:

Download Chrome Driver


Download the latest version of Google Chrome Driver (for now it’s 2.22) depending upon your Operating System.

Follow below steps:

  • Clicking on the latest version link will navigate you to another page.
  • Right Click the respective link that you want to download as per your system’s requirement.
  • Click on Save link as .
  • Select System path where you want to save the files
  • The download will start.
  • Extract Zip file.
  • We are all set with chromedriver.exe .

So these were the pre-requisites before we actually jump to the code section.

To work with Chrome Driver, first, we have set the value of a System variable (“webdriver.chrome.driver”) with the path of Driver Exe file, which WebDriver internally uses to refer to Chrome Driver.

System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");
ChromeDriver chromeDriver = new ChromeDriver();

setProperty 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 API’s 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

Leave a Comment: