Gardening

Step-by-Step Guide- Installing ChromeDriver on Ubuntu Linux

How to Install Chrome Driver in Ubuntu

Installing ChromeDriver on Ubuntu is a straightforward process that allows you to automate web applications using Selenium WebDriver. ChromeDriver is a standalone server that enables you to run your Selenium tests against Google Chrome. In this article, we will guide you through the steps to install ChromeDriver on Ubuntu.

Step 1: Check Your Ubuntu Version

Before you begin, ensure that you are running a compatible version of Ubuntu. ChromeDriver is compatible with most Ubuntu versions, including Ubuntu 18.04, 20.04, and 21.10. You can check your Ubuntu version by opening a terminal and typing the following command:

“`
lsb_release -a
“`

Step 2: Install Prerequisites

To install ChromeDriver, you will need to install some prerequisites. Open a terminal and run the following commands to install the necessary packages:

“`
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk
sudo apt-get install -y unzip
“`

Step 3: Download ChromeDriver

Next, you need to download the ChromeDriver package from the official website. Go to the ChromeDriver download page and select the version that matches your Chrome browser version. Once you have downloaded the ChromeDriver package, extract it using the following command:

“`
unzip chromedriver_linux64.zip
“`

Step 4: Set ChromeDriver Permissions

To run ChromeDriver as a non-root user, you need to set the appropriate permissions. Open a terminal and navigate to the extracted ChromeDriver directory:

“`
cd chromedriver
“`

Then, set the executable permission for the ChromeDriver binary:

“`
chmod +x chromedriver
“`

Step 5: Verify ChromeDriver Installation

To verify that ChromeDriver has been installed correctly, open a new terminal window and run the following command:

“`
./chromedriver –version
“`

If the command returns the version number of ChromeDriver, it means that the installation was successful.

Step 6: Add ChromeDriver to Your PATH

To make ChromeDriver accessible from any terminal, you need to add it to your PATH environment variable. Open your `.bashrc` file in a text editor:

“`
nano ~/.bashrc
“`

Add the following line to the end of the file:

“`
export PATH=$PATH:/path/to/chromedriver
“`

Replace `/path/to/chromedriver` with the actual path to the ChromeDriver binary. Save and close the file.

Step 7: Restart Your Terminal

To apply the changes to your PATH environment variable, restart your terminal or run the following command:

“`
source ~/.bashrc
“`

Conclusion

Congratulations! You have successfully installed ChromeDriver on Ubuntu. Now you can use it to automate web applications with Selenium WebDriver. Remember to update ChromeDriver regularly to ensure compatibility with the latest versions of Chrome and Selenium.

Related Articles

Back to top button