Loading...

How to Install Selenium on CentOS 7

Simple.Predictable.Scalable

Easily deploy your favorite applications in seconds at an unbeatable price for your next projects.

Installing Selenium on CentOS 7

Selenium is a powerful open-source tool for automating web browsers. It allows you to automate browser activities such as filling out forms, clicking buttons, and navigating through web pages. In this guide, we will walk you through the steps to install Selenium on CentOS 7.

Prerequisites

Before installing Selenium, make sure you have the following:

  • A CentOS 7 server
  • Root or sudo access
  • Google Chrome or Mozilla Firefox

Step 1: Install Java

Selenium requires Java to run. You can install Java by following these steps:

$ sudo yum install java-1.8.0-openjdk

Step 2: Install ChromeDriver or GeckoDriver

If you are using Google Chrome, you need to install ChromeDriver. If you are using Mozilla Firefox, you need to install GeckoDriver. Follow the steps below based on the browser you are using:

Install ChromeDriver

# Install ChromeDriver dependencies $ sudo yum install -y unzip  # Download ChromeDriver $ wget https://chromedriver.storage.googleapis.com/$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE)/chromedriver_linux64.zip  # Extract the downloaded archive $ unzip chromedriver_linux64.zip  # Move the extracted binary to /usr/bin/ $ sudo mv chromedriver /usr/bin/chromedriver  # Add execute permissions to the binary $ sudo chmod +x /usr/bin/chromedriver

Install GeckoDriver

# Install GeckoDriver dependencies $ sudo yum install -y libX11  # Download GeckoDriver $ wget https://github.com/mozilla/geckodriver/releases/download/v0.28.0/geckodriver-v0.28.0-linux64.tar.gz  # Extract the downloaded archive $ tar -xvf geckodriver-v0.28.0-linux64.tar.gz  # Move the extracted binary to /usr/bin/ $ sudo mv geckodriver /usr/bin/geckodriver  # Add execute permissions to the binary $ sudo chmod +x /usr/bin/geckodriver

Step 3: Install Selenium

Now, let's install Selenium using the Python package manager, pip:

$ sudo yum install -y python3-pip  # Install Selenium $ sudo pip3 install selenium

Step 4: Test Selenium

Finally, let's test if Selenium is successfully installed. Create a new Python file, for example, "selenium_test.py", and add the following code:

from selenium import webdriver  # Create a new Chrome or Firefox driver driver = webdriver.Chrome()  # for Chrome # driver = webdriver.Firefox()  # for Firefox  # Open a website driver.get("https://www.example.com")  # Print the page title print(driver.title)  # Close the driver driver.quit()

Save the file and run it to see if Selenium is working correctly:

$ python3 selenium_test.py

If everything is set up correctly, it should open a browser window, navigate to "https://www.example.com" and print the page title. Once the script finishes, the browser window will close.

Congratulations! You have successfully installed Selenium on CentOS 7.

Refer A Friend
Get $25

installing Selenium
CentOS 7
Selenium installation
CentOS 7 Selenium
Selenium on CentOS
Selenium on CentOS 7
Selenium CentOS 7 installation
CentOS 7 Selenium setup
Selenium setup on CentOS 7
CentOS 7 Selenium configuration

Why Customers Love Us

What our customers say about us

Ready To Get Started For Free?

Create your free account today.