Selenium integration with Jenkins in Ubuntu

Selenium integration with Jenkins in Ubuntu

Jenkins is open-source integration tool written in Java. It can be run on cross-platforms-  Windows, Linux, Mac OS and Solaris environments. Advantage of Jenkins is in its ability to checkout test scripts from repositories in SVN, Github, Bitbucket and build the test from test scripts . Jenkins can be configured to schedule test runs like cron jobs as and when desired .

Prerequisites for Selenium integration:

Ubuntu server, Jenkins

Java , Maven, Packages for Chrome and Firefox

Here we go creating the environment with the above prerequisites

Ubuntu Server Information:

Execute below command on terminal:

cat /etc/lsb-release 

Java installation:
Execute below command on terminal:

sudo apt-get install -y openjdk-7-jdk

Maven installation:
Execute this command on terminal:

sudo apt-add-repository -y ppa:andrei-pozolotin/maven3
sudo apt-get update
sudo apt-get install -y maven3

Jenkins installation:
Install Jenkins from Debian package repository of Jenkins . To use this repository, first add the key to your system:

wget -q -O - | sudo apt-key add -

Next, add the following entry in /etc/apt/sources.list:

deb binary/
sudo apt-get update
sudo apt-get install jenkins
service jenkins start

Packages installation for Firefox & Chrome browser:

yum install wget unzip
cp chromedriver /usr/bin/
chmod 755 /usr/bin/chromedriver
wget -q -O - | sudo apt-key add -
sudo sh -c 'echo "deb stable main" >> /etc/apt/sources.list.d/google-chrome.list'

Accept installation of fonts ( though they are not really necessary) to avoid annoying warnings.

xvfb can start a virtual X window on a server where Selenium can start the browser to run the tests.

Xvfb or X virtual frame buffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without any output screen.


sudo apt-get update && sudo apt-get install -y xfonts-100dpi xfonts-75dpi xfonts-
scalable xfonts-cyrillic xvfb x11-apps  imagemagick firefox google-chrome-stable

Configurations at Jenkins:
Plugins: Github, Xvfb

Step 1 ? Go to Manage Plugins by clicking “Manage Jenkins”

Step 2 ? Find the Xvfb Plugin and choose to install. Restart the Jenkins instance

Step 3 ? Again Go to Manage Plugins & Find the GitHub Plugin and choose to install. Restart the Jenkins instance

Step 4 ? Go to Configure system

Make sure Maven, Xvfb, Global properties configured properly in jenkins –

Steps to run Selenium  with Jenkins (a sample  web test case) :

Test case is to launch the chrome browser and navigates to  the bimarian web site (

Create Maven project:
Click on “New Item” in Jenkins, give item name as “selenium-web-test” & select “Maven project” then click  OK ,it will navigate to project configuration page

In configuration page – select “Git” in Source Code Management & provide Repository URL –

Chrome browser  runs on Headless Linux server – so we need Xvfb to display the screen virtually. Xvfb plugin already installed will take care of start/stop Xvfb in build process . Select Start Xvfb before the build, and shut it down after” in Build Environment and click on advanced button then configure properties as shown below: (refer the screenshot)

  • Xvfb specific display name: 99
  • I’m running this job in parallel on same node: select checkbox
  • Timeout in seconds: 0
  • Xvfb screen: 1024x768x8
  • Xvfb display name offset: 1


Configure Build with  properties mentioned below 
Root POM: xml
Goals and options: clean test

Save the project

Execute “Build Now” & check the build status


Leave a Reply



6 April 2020 | 11:00 AM PST

Join the Standav Team & Frank Sohn from Novus CPQ, with Special Guests from Bayer, Box, Extreme Networks, Miro, Mobileiron, and Ross Video as we discuss CPQ, Billing, and Pricing Solutions for the Enterprise.

You have successfully registered! You will receive the details to join the conference.