How To Setup Selenium With ChromeDriver On Ubuntu 22.04, 20.04 & 18.04

This tutorial will help you to install and set up Selenium with ChromeDriver on Ubuntu Ubuntu 22.04, 20.04 & 18.04. This is also applicable for the Linux Mint.

How To Setup Selenium With ChromeDriver On Ubuntu 22.04, 20.04 & 18.04

At first, You need to install required packages on your Ubuntu. Run the following command to install Xvfb (X virtual framebuffer) in Ubuntu.

sudo apt update
sudo apt install -y unzip xvfb libxi6 libgconf-2-4

Meanwhile, you also need to have Java installed in your Ubuntu.

sudo apt install default-jdk

Now, Run the following commands to install Google Chrome.

sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add 
sudo bash -c "echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list"
sudo apt -y update  
sudo apt -y install google-chrome-stable

Now, It’s time to install ChromeDriver on your Ubuntu.

Run the following command to find out the Google chrome version installed on your system.

google-chrome --version

Output

Google Chrome 94.0.4606.61

Next, you need to download the matching version of chromedriver with your Google Chrome on your Ubuntu from the Chromedriver download page.

wget https://chromedriver.storage.googleapis.com/94.0.4606.61/chromedriver_linux64.zip 
unzip chromedriver_linux64.zip

Now, run the following commands to configure ChromeDriver on your Ubuntu.

sudo mv chromedriver /usr/bin/chromedriver  
sudo chown root:root /usr/bin/chromedriver  
sudo chmod +x /usr/bin/chromedriver

Download Selenium Server Jar Files

Download the Selenium standalone server jar file using the below commands.

wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar  
mv selenium-server-standalone-3.141.59.jar selenium-server-standalone.jar

Also, download the testng-6.8.7.jar file to your system.

wget http://www.java2s.com/Code/JarDownload/testng/testng-6.8.7.jar.zip  unzip testng-6.8.7.jar.zip 

Now, You need to start Chrome via a standalone selenium server using the Xvfb utility that you have installed in first step.

xvfb-run java -Dwebdriver.chrome.driver=/usr/bin/chromedriver -jar selenium-server-standalone.jar

Run the following command if you want to Start Headless ChromeDriver.

chromedriver --url-base=/wd/hub

At this moment,Your Selenium server is now running with Chrome. Let us know if you have any other method to Setup Selenium With ChromeDriver On Ubuntu 22.04, 20.04 & 18.04.

Leave a comment

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