Set up and run Selenium on CentOS

Pavan Kumar
4 min readJun 30, 2020

Getting Selenium + Chrome + CentOS up was a nightmare. After hours, I switched over to Firefox and it worked in 5 minutes. No additional driver needed either.

Check version of CentOS

$ cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)

Prerequisites for Selenium Setup in CentOS 7 :

1.Install latest version of Java and set the path variables

2.Install latest version of Chrome and Firefox browser

3.Install latest version of Selenium server

4.Download chromedriver and geckodriver compatible with browsers

5.Install xvfb

Installation Steps :

Install Java:

$ sudo apt-get install default-jdk

Install Google Chrome:

$ curl https://intoli.com/install-google-chrome.sh | bash

$ sudo yum install google-chrome-stable

Please refer this link : https://intoli.com/blog/installing-google-chrome-on-centos/

Install Chrome Driver:

$ wget https://chromedriver.storage.googleapis.com/index.html?path=81.0.4044.69/

$ unzip chromedriver_linux64.zip

Execute below commands to configure Chrome Driver:

$ sudo mv chromedriver /usr/bin/chromedriver

$ sudo chown root:root /usr/bin/chromedriver

$ sudo chmod +x /usr/bin/chromedriver

Install Apache-maven 3.5.4V :

https://linuxize.com/post/how-to-install-apache-maven-on-centos-7/

Install git :

$ sudo yum install git

To install xvfb on machine :

1.Open Terminal

2.Switch to root user

3.Then type “ # yum install xorg-x11-server-Xvfb “ click Enter (downloads)

4.Then type “# yum -y groupinstall “X Window System” “Desktop” “Fonts” “General Purpose Desktop” click Enter (downloads)

5.Then type “$ Xvfb :99 -ac -screen 0 1280x1024x24 & “ click Enter

6.Then type “$ export DISPLAY=:99”

Configuring Jenkins :

Step 1 — Install Jenkins

Step 2 — Configuring System

a) Go to Manage Jenkins->Configure System

b) Configure JDK
-Give the JDK name
-JAVA_HOME : C:\Program Files\Java\jdk1.7.0_45

c) Maven configuration
-Give a maven name
-MAVEN_HOME : C:\apache-maven-3.2.5\apache-maven-3.2.5-bin\apache-maven-3.2.5

d) Global Maven_OPTS
–Xmx512m
–XX:MaxPermSize=128m

e) Save once done

Step 3 — Adding Plugins

a) Go to Manage Jenkins->Add Plugins

b) Install the plugins which are required, Eg. GIT client plugin: which Shared library plugin for other Git related Jenkins plugins, GIT plugin: This plugin integrates GIT with Jenkins etc.

Step 4 — Creating jobs

a) Go to New Items->Give a project name in “Item name” field->select Maven project->click OK

b) Now configure the job
-Provide the description
-In Source Code Management, there are options Select Git select the one which is required

  • Enter the Repository URL and Credentials

– In Build Triggers, there are multiple options like “Build when a change is pushed to GitHub”, “Poll SCM”, “Build whenever a SNAPSHOT dependency is built” etc, select the required one
— Give the path of your pom.xml file in Build Root POM
— Give “Goals and options“ take a use case where the requirement is to install the code then give ”clean install”

c) Configure the job as in the screenshot and don’t forget to save

d) In the same way, create another job(4503_deploy)

e) Suppose the requirement is creating two jobs, one(4502_deploy) for deploying the code on author instance 4502 and if it’s built is successful than it should run its downstream job(4503_deploy) for deploying code on publishing instance.

f) Now configure the job “4502_deploy”, In Post Steps select “Run only if build succeeds”

g) In Post Build Action, add post build action and give the job name(4503_deploy) in “Projects to build

Step 5 — Build the jobs

--

--

Pavan Kumar

6+ years of Testing experience in automation using Selenium (Java). Expertise in API and Performance testing . Interested in Full Stack Development