---Advertisement---

Maven and Jenkins Integration with Selenium: Complete Step-by-Step Guide Best 2025

By Manisha

Updated On:

---Advertisement---
Maven and Jenkins Integration with Selenium

Jenkins is an open-source continuous integration (CI) tool that automates the software development process. It helps developers by continuously building and testing applications in various environments, reducing manual effort.

Key Features of Jenkins:

  • Automated Testing & Deployment – Runs tests and deploys software automatically after changes.
  • Integration with Version Control – Supports SVN, Git, and other repositories for tracking changes.
  • Easy Installation & Configuration – Simple setup on Windows, Linux, and Mac OS.
  • Email Notifications – Sends build status reports to teams.
  • Supports Plugins – Easily extend functionality with third-party plugins.
  • TestNG Integration – Automates Selenium test execution.

Why Integrate Selenium with Jenkins?

  • Automates execution of Selenium tests with each software update.
  • Schedules test execution at specific times.
  • Generates reports on test history and performance.
  • Reduces manual testing effort and enhances software quality.
  • Works seamlessly with Maven for dependency management.

Maven and Jenkins Integration with Selenium: Maven is a powerful build automation tool used for managing Selenium test projects. It helps in dependency management, project structure standardization, and automating the build process.

Advantages of Using Maven with Selenium

  • Manages Dependencies – Automatically downloads required libraries.
  • Standardized Project Structure – Ensures consistency in test projects.
  • Automates Build & Test Execution – Reduces manual efforts.
  • Supports TestNG & JUnit – Runs tests efficiently.

Step 1: Install Maven Plugin in Eclipse

  1. Open Eclipse and go to Help > Install New Software.
  2. Enter URL: https://www.eclipse.org/m2e/.
  3. Select m2e Plugin and click Install.

Step 2: Create a Maven Project in Eclipse

  1. Go to File > New > Other > Maven > Maven Project.
  2. Select “Create a Simple Project” and click Next.
  3. Enter Group ID as WebdriverTest and Artifact ID as MavenProject.
  4. Click Finish to create the project.

Step 3: Add Dependencies in pom.xml

Modify the pom.xml file and add the following dependencies:

xml<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
</dependency>
</dependencies>
  1. Maven and Jenkins Integration with Selenium: In Eclipse, right-click on src/test/java and create a new package example.
  2. Inside the package, create a new TestNG class named NewTest.java.
  3. Add the following test script:
javaimport org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class NewTest {
@Test
public void testGoogleHomePage() {
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
System.out.println("Title: " + driver.getTitle());
driver.quit();
}
}
  1. Convert the test class into TestNG format (Right-click > Convert to TestNG).

Step 5: Run Tests Using Maven

  1. Right-click on the project > Run As > Maven Test.
  2. Maven will download dependencies and execute the test script.

Step 1: Install Jenkins

  1. Maven and Jenkins Integration with Selenium: Download Jenkins from
  2. Install Jenkins and start the service.
  3. Open http://localhost:8080 in a browser to access Jenkins Dashboard.

Step 2: Create a New Jenkins Job

  1. Maven and Jenkins Integration with Selenium: Click New Item > Maven Project > Enter project name (WebdriverTest).
  2. Click OK to create the job.

Step 3: Configure Maven & JDK in Jenkins

  1. Go to Manage Jenkins > Global Tool Configuration.
  2. Add JDK installation path.
  3. Add Maven installation path.

Step 4: Configure Jenkins Job for Selenium Execution

  1. In the Build section, enter:
    • Root POM: Full path to pom.xml.
    • Goals & Options: clean test
  2. Click Save.

Step 5: Run Tests in Jenkins

  1. Click Build Now to trigger execution.
  2. Monitor build logs in Console Output.
  3. View Test Reports under Build History.

Automating Test Execution in Jenkins

Maven and Jenkins Integration with Selenium: To schedule automated test execution, configure Build Triggers:

  • Schedule Daily Execution:
    • Go to Build Triggers section.
    • Enter 0 23 * * * (Runs every day at 11 PM).
    • Click Apply & Save.

Maven and Jenkins Integration with Selenium: If Maven is not used, execute TestNG scripts directly in Jenkins using:

shjava -cp "path/to/lib/*;path/to/bin" org.testng.TestNG testng.xml
  • Modify paths accordingly before running.
  • Jenkins will store results in a custom HTML report for email notifications.

Early Bug Detection – Continuous integration finds issues faster.
Automated Test Execution – No manual intervention needed.
Parallel Execution – Run tests on multiple environments.
Report Generation – Stores test history & execution reports.
Scalability – Supports distributed builds on multiple machines.


Maven and Jenkins Integration with Selenium: Integrating Jenkins with Maven & Selenium simplifies test execution, ensuring automated, scalable, and efficient testing. By following this guide, you can set up continuous integration, schedule tests, generate reports, and streamline automation workflows.


Let me know if you need customized configurations, troubleshooting tips, or best practices for Selenium-Jenkins integration!

Selenium Grid Tutorial
Jenkins Download

Leave a Comment

Index