Integration Of Jenkins With Selenium WebDriver


What is Jenkins?

Jenkins is a well-known open-source tool that aids in the implementation of Continuous Integration (CI) and Continuous Deployment/Continuous Delivery (CD) processes by automating parts of the software development pipeline such as building, testing, and deployment.

What is Selenium?

Selenium is an open-source automation tool that has been widely used for testing web applications.  It is basically a suite of software or a set of JAR files to automate web browsers across various browsers. Selenium is used by many companies, but a few to mention are Netflix, Google, HubSpot, Fitbit, and more.  Selenium supports multiple languages like Python, Pearl, Ruby, .Net, Java, C#, PHP. 

Selenium supports parallel test execution. That means we can open multiple browsers at the same time and execute the test cases. This decrease the execution time significantly. Selenium supports Cross browser test execution.

Jenkins Integration With Selenium 

It is recommended to go through these tutorials:-

Download and install Jenkins on Windows10


Implementation Steps

Step 1 – Create a project for running the tests using Selenium WebDriver and TestNG

Step 2 – Create the Test Code

Below is the sample POM.xml.

<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">




		<!-- Selenium -->

		<!-- TestNG -->

		<!-- Web Driver Manager -->

		<!-- Allure Report -->	




package com.example;

import org.openqa.selenium.WebDriver;

public class BasePage {
	  public WebDriver driver;

	  public BasePage(WebDriver driver) {
		  this.driver = driver;



import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class HomePage extends BasePage {

	public HomePage(WebDriver driver) {


	  @FindBy(xpath = "//*[@id='app']/div[1]/div[1]/header/div[1]/div[1]/span/h6")
	  public  WebElement homePageUserName;

	  public String getHomePageText() {
	       return homePageUserName.getText();



import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class LoginPage extends BasePage{
	 public LoginPage(WebDriver driver) {
	@FindBy(name = "username")
    public WebElement userName;
    @FindBy(name = "password")
    public WebElement password;
    @FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button")
    public WebElement login;
    @FindBy(xpath = "//*[@id='app']/div[1]/div/div[1]/div/div[2]/div[2]/div/div[1]/div[1]/p")
    public  WebElement errorMessage;
    public void login(String strUserName, String strPassword) {
    public String getErrorMessage() {
        return errorMessage.getText();


import java.time.Duration;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import io.github.bonigarcia.wdm.WebDriverManager;

public class BaseTests {
	public static WebDriver driver;
	public final static int TIMEOUT = 10;    
    public void setup() {
	    driver = new ChromeDriver();

    public void tearDown() {


import org.testng.Assert;
import org.testng.annotations.Test;

public class LoginPageTests extends BaseTests{

    public void invalidCredentials() {
	    LoginPage objLoginPage = new LoginPage(driver);
    	objLoginPage.login("admin$$", "admin123");
    	// Verify Error Message
    	 Assert.assertEquals("Invalid credentials",objLoginPage.getErrorMessage());

    public void validLogin() {
	    LoginPage objLoginPage = new LoginPage(driver);
    	objLoginPage.login("Admin", "admin123");
    	HomePage objHomePage = new HomePage(driver);
    	// Verify Home Page

Step 3 – Start Jenkins

Open the Jenkins dashboard – http://localhost:8081/.  In the Jenkins dashboard, click New Item to create a new project.  

Step 4 – Create a FreeStyle project in Jenkins

Specify the name of the project and click the Freestyle Project option. Click the OK button.

Step 5 – Mention the description

In the General section, enter the project description in the Description box.

Step 6 – Source Management

In the Source Code Management section, select None.


Step 7 – Select Invoke top-level Maven targets in build steps

In the Build Steps section, select Invoke top-level Maven targets.

Step 8 – Provide the build steps

The Build Steps window will extend. Mention the below details:-

Maven Version – MAVEN_HOME

Goals – clean test

Click on the Advanced button.

Step 9 – Mention the path of the project

Specify the full path to pom.xml in POM. Click on the Apply Button and then on the Save button.

Step 10 – Verify the the project is created in Jenkins

The below screen shows that a new project with the name of SeleniumTestNGDemo is created.

Step 11 – Execute the tests

Click on the Build Now option to run the tests.

Step 12 – View the execution result

Click on the Console Output to see the test execution result.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

Additional Tutorials on Jenkins


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s