Open In App

How to Install Selenium Tools on Linux?

Last Updated : 28 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Installing Selenium tools on Linux is a crucial step for developers and testers who want to automate web applications in a Linux environment. Selenium is a powerful tool that supports various programming languages and is widely used for browser automation. Setting up Selenium on Linux involves installing essential components like Java, WebDriver, and a browser driver compatible with your preferred browser (such as ChromeDriver for Google Chrome).

This guide will walk you through the process, ensuring a smooth setup for running Selenium tests on your Linux system

Installing Selenium Tools on Linux

To install Selenium Tools on Linux follow the following steps:

Step 1: Install Java. Java must be installed on your computer. Install Oracle Java 8 or OpenJDK with the command below.

sudo apt update

sudo apt install openjdk-11-jdk -y

sel-GFG

Step 2: Install Google Chrome. Using the commands shown below, install the most recent Google Chrome package on your PC.

wget -N https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/google-chrome-stable_current_amd64.deb

sudo apt install -y /tmp/google-chrome-stable_current_amd64.deb

finalgfg1

Step 3: Install Chrome Webdriver. You must also install ChromeDriver on your computer. It is a standalone server for Chromium that is used to implement WebDriver wire protocol. It is an open-source tool for testing web applications. So to check the version of Google Chrome installed on your system write the following command in the terminal.

google-chrome --version 

finalgfg2

Next, go to the ChromeDriver download page and download Chromedriver on your system.

Note: you can add the latest stable version of chrome in place of ${version}.

wget -N https://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip -O /tmp/chromedriver_linux64.zip

finalgfg3

Now execute the below commands to configure ChromeDriver on your system.

unzip /tmp/chromedriver_linux64.zip -d /tmp/chromedriver/

sudo cp /tmp/chromedriver/chromedriver /usr/local/bin/chromedriver

chromedriver -v

Step 4: Download Required JAR files. To use Remote Selenium WebDrivers, you'll need the Selenium Server. Use the following commands below to get the Selenium server jar file, or you can download the latest version from the official website.

wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.11.0/selenium-server-4.11.0.jar -O selenium-server.jar

finalgfg5

Step 5: Start Chrome via Selenium Server. The server is set up and ready to go. Using the xvfb utility, we will start Chrome via the selenium server.

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

Start-Chrome-via-Selenium-Server

You might need to first install xvfb which can be done using the following command.

sudo apt install xvfb -y

Now you are all set to use Selenium Tools.

Conclusion

By following the steps outlined in this guide, you will successfully install Selenium tools on Linux and be ready to start automating your web testing tasks. With Selenium properly configured, you'll have the flexibility to run automated tests in a robust and scalable Linux environment, ensuring your web applications perform as expected across different platforms. Make sure to keep your tools updated to take advantage of the latest features and security enhancements, optimizing your Selenium testing experience on Linux


Next Article

Similar Reads