App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to run Selenium tests on Chrome using ChromeDriver?

How to run Selenium tests on Chrome using ChromeDriver?

By Jash Unadkat, Community Contributor -

Table of Contents

Google Chrome dominates the browser market with a massive 64% global market share. With several useful features, it is one of the most preferred browsers in the world. Given its importance and usage, testing all websites on Chrome becomes crucial.

This article will explain how to perform Selenium tests on a Chrome browser using ChromeDriver. But before that, let’s understand what ChromeDriver is and how users can configure it on their systems.

What is a Selenium ChromeDriver?

A ChromeDriver is a standalone server or a separate executable used by Selenium WebDriver to control Chrome. Running Selenium test scripts on the Google Chrome browser is impossible without ChromeDriver. One can easily initialize the object of ChromeDriver using the following command:

WebDriver driver = new ChromeDriver

How to configure ChromeDriver?

Step 1 – Download ChromeDriver

First, download the ChromeDriver. Users need to download ChromeDriver for their respective Operating systems from this link. Refer to the image to get a better sense of ChromeDriver downloads.

Selenium ChromeDriver

Step 2 – Retrieve the chromedriver.exe File

Once the zip file is downloaded for the operating system, unzip it to retrieve the chromedriver.exe executable file. Copy this file to a specific location of your choice.

Step 3 – Set environment variables 

Now copy the path where the ChromeDriver file is saved to set the system properties in environment variables. Follow the steps below to set the path in the environment variables:

1. Right-click on My Computer and click on Properties

Selenium ChromeDriver

Image source

2.  Click on the Change settings option and then click on the Advanced tab

3.  Now select the Environmental variables from the Advanced tab

Selenium tests on Chrome

4. Now, from the available options under system variables, select the Path option and click on Edit

Selenium with ChromeDriver

5. At the end of the string, enter a semicolon ‘;’ and paste the path of your ChromeDriver file that you copied earlier, and click OK.

Heard about SafariDriver? Learn how to how to run Selenium Tests on Safari using SafariDriver.

Steps for macOS users:

  1. Go to the terminal and type the command: sudo nano /etc/paths
  2. Enter the password
  3. At the bottom of the file, add the path of your ChromeDriver
  4. Type Y to save
  5. To exit press Control + C

Steps to run Selenium Tests on Chrome Browser

Let’s discuss how to run Selenium scripts on a Chrome browser using ChromeDriver.

  1. Install the Eclipse Integrated Development Environment (IDE) and import all the Selenium dependencies into the project directory. (Users can use other IDEs, too as per their choice)
  2. Set the properties by specifying the type of driver to be used along with its path describing where it is stored.
  3. Initialize the object of the ChromeDriver. This helps in launching the Chrome browser.
  4. To navigate to a particular URL, use the driver.get() method. One can also locate certain web elements using specific locators. To know more about locating elements in Selenium, refer to this detailed guide on Locators in Selenium.

Pro Tip: Want to dive deeper into Selenium implementation on BrowserStack with free interactive courses and lab exercises? Visit Test University

Now let’s consider a test case example wherein we want to perform 3 simple steps:

  1. Open Chrome Browser
  2. Go to
  3. Enter Youtube in the search text box

Did you know: There are more than 98 Chrome Browser versions to test on. Don’t miss out on testing across!

Refer to the code snippet below to get a better sense of executing the steps mentioned above:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
public class ChromeExample {
public static void main(String[] args) {

//Setting system properties of ChromeDriver
System.setProperty("", "C://Selenium-java browserstack//chromedriver_win32//chromedriver.exe");

//Creating an object of ChromeDriver
WebDriver driver = new ChromeDriver();

//Deleting all the cookies

//Specifiying pageLoadTimeout and Implicit wait
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

//launching the specified URL

//Locating the elements using name locator for the text box

//name locator for google search button
WebElement searchIcon = driver.findElement("btnK"));;

When the above program is executed, the ChromeDriver launches the Chrome browser, opens the Google website, and enters the value Youtube in the search box. This is how one can run Selenium tests in Chrome using ChromeDriver.

Run Selenium Tests using ChromeDriver

  • Although it’s vital to test web-apps for Chrome, it’s also important for a web app to be optimized for other browsers like Firefox, Safari, Edge, etc.
  • Teams can leverage  BrowserStack, which enable QAs to perform cross browser testing for their web apps across thousand of real browsers and browser versions like Safari, Opera, Edge, etc.
  • All real browsers are installed on real desktop and mobile devices, thus providing the optimal environment for software testing in real user conditions.

Frequently Asked Questions (FAQs)

1. How to use Selenium WebDriver ChromeDriver?

The following are the steps to use Selenium WebDriver ChromeDriver:

  1. Download and install the latest version of ChromeDriver.
  2. Install the Selenium WebDriver client for your programming language (e.g., Python, Java, Ruby).
  3. Import the necessary packages in your code to use Selenium WebDriver and ChromeDriver.
  4. Create a new instance of ChromeDriver in your code.
  5. Use the instance to automate actions in the Chrome browser (e.g., navigating to a URL, filling out a form).

2. Are there any prerequisites for using Selenium WebDriver ChromeDriver?

Yes, you need to have a basic understanding of a programming language and its syntax. You must also have installed the latest versions of Chrome browser, ChromeDriver, and Selenium WebDriver client for your chosen programming language.

3. Which Selenium WebDriver do we need to execute tests in the Chrome browser?

  • To execute tests in the Chrome browser using Selenium WebDriver, you need to use ChromeDriver.
  • ChromeDriver is a separate executable used by Selenium WebDriver to control the Chrome browser.
  • Download the latest version of ChromeDriver and control the Chrome browser during your tests.
  • Use the version of ChromeDriver that matches the version of your Chrome browser.
Selenium Selenium Webdriver

Featured Articles

Chrome vs Chromium: Core Differences

Exception Handling in Selenium WebDriver

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.