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:
- Open Chrome browser.
- Click on the three dots in the top right corner of the browser.
- Go to Help > About Google Chrome.
- The version number of Chrome will be displayed.
You can check the version of Chrome by following below image steps.
![check-chrome-version](https://kushalstudy.com/wp-content/uploads/2023/04/check-chrome-version.jpg)
You will see the below page of Chrome which shows the version of your Chrome browser.
![chrome-version](https://kushalstudy.com/wp-content/uploads/2023/04/chrome-version.jpg)
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](https://kushalstudy.com/wp-content/uploads/2023/04/chromedriver-download.jpg)
For Chrome version 115 or newer, click on the below-marked link which contains chromedriver for a newer version of Chrome.
![new-version-chrome](https://www.kushalstudy.com/wp-content/uploads/2023/04/new-version-chrome-1024x127.jpg)
Then click on Stable version of Chromedriver as shown in the below image.
![stable-chromedriver](https://www.kushalstudy.com/wp-content/uploads/2023/04/stable-chromedriver.jpg)
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](https://www.kushalstudy.com/wp-content/uploads/2023/04/copy-chromedriver-url-1024x133.jpg)
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:
- Extract the downloaded Chrome WebDriver zip file.
- Move the extracted file to a location where it will be accessible from the Python script.
- 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:
- Open Control Panel > System > Advanced System Settings > Environment Variables.
- Under System Variables, select PATH and click Edit.
- Click New and add the directory path (C:\WebDriver\ in this case).
- Click OK and close all windows.
![adding-chromedriver-in-path](https://kushalstudy.com/wp-content/uploads/2023/04/adding-chromedriver-in-path.jpg)
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](https://kushalstudy.com/wp-content/uploads/2023/04/chromedriver-output.jpg)
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.