What is ChromeDriver?

Nishil Patel

Nishil Patel

Jul 18, 2024

8 min read

Share

What is ChromeDriver?

ChromeDriver enables communication between your web apps and the Chrome browser. You can configure it to run software tests across the browser right from your local machine or through remote setup.

Table of Contents

1.

Introduction

2.

What is ChromeDriver?

3.

What is WebDriver?

4.

What are “Capabilities” in WebDriver?

5.

Relationship Between WebDriver and ChromeDriver

6.

What Exactly Does ChromeDriver Do, and What Can You Do With It?

7.

How Does It Help in Automation?

8.

Setting Up ChromeDriver

9.

How ChromeDriver is Used in Automated Testing Frameworks like Selenium

10.

How to Configure ChromeDriver for Selenium?

11.

Use Cases for ChromeDriver

12.

Common Issues and Troubleshooting

13.

Best Practices for Using Chrome Driver

14.

How to Stay Informed About New Releases And Updates

15.

FAQs

Introduction

If you're looking for a browser that reigns supreme on the internet, Google Chrome stands out unequivocally. With over 3.45 billion users and commanding an impressive 63.87% share of the global browser market, Chrome is ubiquitous across modern devices, from laptops to smartphones. Web apps interact with Chrome through an executable driver file known as ChromeDriver. Let's dive in.

What is ChromeDriver?

ChromeDriver is an executable file that lets you control and run automation tests of web apps within the Chrome browser. It's a free-to-use driver that functions as a standalone server and enables communication between your test scripts and the Chrome browser.

ChromeDriver implements the W3C WebDriver standard by extending the WebDriver class with Chromium-specific capabilities. Capabilities are key-value pairs (just like in an object). You can configure them to run automated test scripts for web apps across browsers. The test scripts can be written in Java, Python, C#, etc.

You can download ChromeDriver for:

  • Chrome on Android devices and
  • Chrome on popular platforms: Windows, MacOS, Linux distros, and ChromeOS.

Also Read: Top 24 Chrome Extensions for Software Testers

What is WebDriver?

WebDriver helps define a standard interface for interacting with web browsers. It's an open-source tool. It abstracts browser-specific details and allows you to write test scripts that work across various browsers (not just Chrome).

It can work with local user agents (like sending HTTP requests in your browser running on your local machine) or with capabilities in remote browser instances.

For example, if your web app places API calls or requires user actions for automation testing (using test scripts), the WebDriver interface takes care of it by communicating with the browser. For Chrome, it's the ChromeDriver that embeds this transactional information.

For instance, you can automate:

  • Navigation between web pages
  • Input values like filling out forms and button clicks
  • Executing JS code within the browser

Also Read: Top 10 Automation Testing Tools

What are “Capabilities” in WebDriver?

Capabilities in WebDriver are key-value pairs that define desired browser behaviors and features. They are programming language-neutral and can be passed as an argument to create a WebDriver instance.

Using capabilities, you can configure browser settings, such as:

  • Browser name and version
  • Page load strategy

Relationship Between WebDriver and ChromeDriver

WebDriver doesn't directly control browsers. Instead, it relies on browser-specific details. For Google Chrome it's the ChromeDriver browser driver (powered by WebDriver).

If you are using Firefox, you would use the GeckoDriver as the browser driver. Similarly, for MS Edge, you’d use Edge WebDriver. Each browser has its corresponding driver that WebDriver communicates with to perform actions.

What Exactly Does ChromeDriver Do, and What Can You Do With It?

ChromeDriver extends the WebDriver class using the ChromeOptions object provided by the WebDriver API. This is for a WebDriver session (or an instance) containing Chromium-specific capabilities. These capabilities enable you to perform actions beyond the standard WebDriver interface.

For instance, you can:

  • Install and manage browser extensions
  • Change window types (e.g., full screen, pop-up)
  • Pass command-line arguments to Chrome on startup

Create Perfect Bug Reports for Devs

How Does It Help in Automation?

ChromeDriver allows you to perform various automation tasks while testing apps on the web. Selenium is a pretty popular automation framework for it (covered in upcoming sections).  It’s especially beneficial while simulating GUI-related features and functions.

For example, you can automate:

  • Basic user actionsExamples: enter text into form fields (username, password, search queries), click buttons and links to navigate through the web app, submit forms, and handle success/failure messages
  • Advanced user actionsExamples: simulate user actions like mouse hovers, drag and drop function, right-clicks, and manage browser cookies (set, get, and delete)
  • Functional testing workflowsExamples: app login with different user credentials (valid, invalid), online shopping cart scenarios (adding/removing items, checkout process), and user registration with various input combinations

Also Read: What is Functional Testing?

Setting Up ChromeDriver

Steps to download ChromeDriver version 115 and above

Here’s a stepwise guide on how to download ChromeDriver for version 115 and above:

Step 1 - Go to the ChromeDriver official downloads page.

Step 2 - To get the latest version, click the “the Chrome for Testing availability dashboard” text.

ChromeDriver-Official-Downloads-Page

This takes you to the download dashboard page. (As of writing this article, version 126 is the latest one available.)

Chrome-Downloads-Dashboard-Page

Step 3 - You can download among Stable, Beta, Dev, and Canary versions. Choose the version based on your platform.

For instance, you can install the latest stable version for Windows.

To start downloading, copy the link for the Win64 option and paste it into your browser tab. This instantly downloads the chromedriver-win64.zip file on your system.

ChromeDriver-Download-Page-View-for-Stable-Version

Step 4 - Next, extract the downloaded zip file to retrieve the chromedriver.exe file.

Step 5 - Lastly, copy and paste the chromedriver.exe application file to your automation project’s root directory.

It’s all set.

Steps to download ChromeDriver version 114 and below

Here’s a stepwise guide on how to download ChromeDriver for version 114 and below:

Step 1 - Go to Google’s official downloads page for version 114 or below. For instance, here’s a link for version chromedriver 114.0.5735.90

Binary-file-download-page-chrome-driver

Step 2 - Next, click on the desired platform to start downloading. For instance, hit chromedriver_win32.zip to start the binary file download.

Binary-file-download-page-chrome-driver

After the download finishes, extract the zip file, and copy the chromedriver.exe application to the root directory of your automation project.

Steps to get a list of all ChromeDriver versions available for download

Step 1 - Open the link here (it takes you to the 114 version download page) and hit “Parent Directory”.

Binary-file-download-page-chrome-driver

Step 2 - It takes you to the index page for all Chrome driver versions, which you can select, click, and download as shown above.

List-of-Chrome-driver-download-versions

How ChromeDriver is Used in Automated Testing Frameworks like Selenium

Selenium WebDriver is widely used to run automated test scripts for web apps in the browser. The Selenium WebDriver is a collection of different APIs for running automated tests.

ChromeDriver is one among many other APIs. It enables Selenium scripts to communicate with the Chrome browser to execute and run automation tests.

How to Configure ChromeDriver for Selenium?

Here are some ways to configure it for different operating systems while using Selenium:

For Windows Users

Here’s how to configure ChromeDriver using environment variables on your Windows machine.

Using Environment Variables

You can define an environment variable at the system level for Selenium to auto-detect the path for ChromeDriver. Simply put, the newly defined system variable points to the location of ChromeDriver. This happens automatically whenever you create a new instance of a WebDriver session.

Here’s how to set up an environment variable for ChromeDriver at the system level:

Step 1 - Once you download, extract, and copy the chromedriver.exe file to your project’s location, copy the location of the executable file.

Step 2 - Search and open “Edit system environment variables” from the Control Panel.

Search-for-Windows-Environment-Variable-Property

Step 3 - Click “Environment Variables” from the “Advanced” tab.

Advanced-Tab-for-Windows-System-Properties-Page

Step 4 - Under the System variables tray, select “Path” and then hit “Edit”.

System-Variables-Tray-for-Windows-Environment-Variables

Step 5 - Click “New” and paste the path location of the previously copied chromedriver.exe file.

New-Environment-variable-for-Windows-Settings-Page

It’s all set now.

Use the following code in your Selenium script to auto-detect the driver from the system variable, whenever you need the ChromeDriver instance:

new_driver = new ChromeDriver();

Using System.setProperty() Method

You can also set the driver path manually in your test script using the System.setProperty() method. Here’s the code:

System.setProperty("webdriver.chrome.driver", "C:\\MyWebApp\\chromedriver.exe");

This method lets you input key: value pairs. Here you’ve:

key: webdriver.chrome.driver
value: C:\\MyWebApp\\chromedriver.exe

That’s it. Your setup is ready to go.

For MacOS Users

Here’s how to configure ChromeDriver using the Mac terminal.

  1. Copy the location path of the chromedriver.exe file.
  2. Open your terminal and run: sudo nano /etc/paths
  3. Type the password
  4. Paste the file path of the exe file you just copied
  5. Hit “Y” to save and then exit with Ctrl + C

Use Cases of ChromeDriver

ChromeDriver is pretty good at performing software testing-related tasks. Using it, you can:

  • Automate form submissions — to fill out forms on web pages and submit them using code logic.
  • Perform data scraping — to extract data from web pages, such as table contents or specific elements.
  • Automate testing — with frameworks like Selenium to execute tests on the Chrome browser.
  • Conduct performance testing — to measure the performance of web apps by simulating user interactions and collecting targeted metrics.
  • Perform cross-browser testing — to test your web apps on different Chrome versions. This helps ensure compatibility across various browser versions.

Also Read: Types of Software Testing Tools

Common Issues and Troubleshooting

Here are some common issues that you may encounter while configuring ChromeDriver and tips to keep them at bay:

  • Compatibility issues — may prevent Chrome Driver from functioning correctly. It's best to use a version of ChromeDriver that’s compatible with your Chrome browser version.
  • Running into path issues — is pretty common. Make sure that the chromedriver.exe file is placed in a location on your system's PATH. If Chrome Driver is not found, double-check the specified path or try moving the executable to a different location.
  • Outdated driver versions — may have bugs or lack support for newer Chrome browser features. It’s good to keep an eye on updates or new version releases.
  • Proxy or firewall issues — sometimes can be the source of errors. Make sure to configure them correctly. Incorrect proxy or firewall settings may interfere with the connection and cause issues.
  • For bugs in your code while using Selenium — it’s best to use Selenium's built-in debugging options or browser devtools to troubleshoot issues.

Capture and Report Software Bugs 10X Faster

Best Practices for Using Chrome Driver

Here is a list of some best practices you can borrow:

  • Use the latest stable versions — of ChromeDriver and Chrome browser to ensure compatibility and take full advantage of bug fixes and new features.
  • Ensure robust error handling — mechanisms in your code to gracefully handle exceptions and unexpected scenarios.
  • Keep your performance settings tuned up — for the ChromeDriver to reduce resource consumption. (e.g., disable unnecessary browser extensions or use headless mode)
  • Implement waits and timeouts — by using explicit and implicit waits in your code. This allows for dynamic web page handling and prevents test failures due to timing issues.
  • Use parallel testing — capabilities of the driver to improve test execution times and efficiency.
  • Leverage bug reporting and logging — tools and mechanisms to track test results, failures, and driver actions for better debugging and analysis.
  • Employ top-notch security practices — such as running tests in a secure environment, sanitizing user input, and handling sensitive data securely.

How to Stay Informed About New Releases And Updates

To stay updated, you can:

  • Subscribe to the Chrome Developer blog — to get updates about ChromeDriver and other Chrome-related tools and technologies.
  • Follow the Selenium page for ChromeDriver on GitHub — to get the latest info about new releases, issues, and discussions.
  • Regularly visit the Chrome for Developers downloads page — to keep in sync with all version release notes and compatibility info.
  • Join Chrome Driver-related mailing lists or forums — such as the Selenium users group, to stay informed about the latest developments, ask questions, or share experiences with fellow users.

FAQs

Chrome sometimes goes haywire due to a temporary glitch, an outdated browser, and conflicting extensions. To fix it, try restarting your computer, closing and reopening Chrome, updating Chrome to the latest version, and disabling extensions one by one to identify the culprit.

Written by

Nishil Patel | CEO & Founder

Follow

Nishil is a successful serial entrepreneur. He has more than a decade of experience in the software industry. He advocates for a culture of excellence in every software product.

Subscribe to our updates

Meet the Author: Nishil Patel, CEO, and Co-founder of BetterBugs. With a passion for innovation and a mission to improve software quality.

We never spam.

Nothing here!
Show us some love 💖. Try BetterBugs today if you haven’t already. A quick feedback and a rating on our Chrome web store page would be awesome!

Share your experience with the founderhere!

Don’t wait! Start reporting now.