How to Install Chrome WebDriver in Selenium Python

How to Install Chrome WebDriver in Selenium Python

Selenium is a popular tool for automating web browsers, and it provides a Python binding for the same. To automate the Chrome browser, we need to install Chrome WebDriver, which is a separate executable that WebDriver uses to control Chrome.

In this blog, we will discuss how to install Chrome WebDriver for Selenium Python.

Step 1: Install Python

Install Python 3.x from the official website. Click on download to get the latest version of Python. Make sure you select Add to PATH, so you can directly use it on Command Prompt.

Confirm Python was installed correctly by opening a new Command Prompt/Powershell and then type the below command:

> python –-version
Python 3.10.2

Step 2: Install Selenium in Python

If you did not install Selenium for Python, you can use pip in Command Prompt / Terminal to install it:

pip install selenium

Step 3: Check Chrome Browser Version

Before installing Chrome WebDriver, we need to check the version of Chrome browser installed on our system. To do this, we can follow these steps:

  1. Open Chrome browser.
  2. Click on the three dots in the top right corner of the browser.
  3. Go to Help > About Google Chrome.
  4. The version number of Chrome will be displayed.

You can check the version of Chrome by following below image steps.

check-chrome-version

You will see the below page of Chrome which shows the version of your Chrome browser.

chrome-version

Step 4: Download Chrome WebDriver

Once we know the version of Chrome, we can download the corresponding version of Chrome WebDriver from the official website: https://chromedriver.chromium.org/downloads as shown below image.

chromedriver-download

For Chrome version 115 or newer, click on the below-marked link which contains chromedriver for a newer version of Chrome.

new-version-chrome

Then click on Stable version of Chromedriver as shown in the below image.

stable-chromedriver

After this, a new page will open. You need to check what your operating system bit, 32bit or 64bit. If it is x64 then copy the URL for win64 chromedriver and open it. The chromedriver will download for your specified chrome.

copy-chromedriver-url

Step 5: Install Chrome WebDriver

After downloading Chrome WebDriver, we need to install it on our system. To do this, we can follow these steps:

  1. Extract the downloaded Chrome WebDriver zip file.
  2. Move the extracted file to a location where it will be accessible from the Python script.
  3. Add the location of the Chrome WebDriver to the PATH environment variable.

For example, if we have extracted the Chrome WebDriver file to the C:\WebDriver\ directory, we can add this directory to the PATH environment variable as follows:

  1. Open Control Panel > System > Advanced System Settings > Environment Variables.
  2. Under System Variables, select PATH and click Edit.
  3. Click New and add the directory path (C:\WebDriver\ in this case).
  4. Click OK and close all windows.
adding-chromedriver-in-path

Step 6: Test Chrome WebDriver

Next, we can now test if Chrome WebDriver is installed correctly by running the following Python script:

from selenium import webdriver

# Create an instance of Chrome WebDriver
driver = webdriver.Chrome()

# Navigate to a web page
driver.get("https://www.kushalstudy.com/")

# Close the browser window
driver.close()

If Chrome WebDriver is installed correctly, a Chrome browser window should open and navigate to the https://www.kushalstudy.com/ website as shown below image. After successfully opening the website, the Chrome browser will close automatically.

chromedriver-output

Conclusion:

Installing Chrome WebDriver for Selenium Python is a straightforward process. By following the above steps, you can install Chrome WebDriver and start automating the Chrome browser using Selenium Python.

Selenium can be installed in different computer programs like Excel VBA. If you want to learn how to install Selenium in Excel VBA, you can check out the blog below.

How to Install Selenium Webdriver for VBA on Windows

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top