Posts Tagged ‘Junit’

WebDriver integration with Jenkins

August 27, 2013 10 comments

WebDriver integration with Jenkins using Maven build tool.

Preconditions :

1. Jenkins should be up and running –

2. Java and Maven should be installed

Through this post, I am trying to say how you can easily integrate WebDriver tests[Java] on Jenkins using Maven build tool.

  1. First Things First – Run Tests on Local First
  • Folder Structure

Create folder structure like below






  • pom.xml

pom.xml file is the basic building block of Maven. Here is a sample pom.xml file for a webdriver test that uses Webdriver latest version and Junit 4.11 version.

<?xml version=”1.0″ encoding=”UTF-8″?>

  • Selenium Scripts

Put your selenium scripts in Java folder [/ProjectName/src/test/java]

  • Run Tests from Terminal

Open Terminal and navigate to Project path [cd /Users/anoop/ProjectName]

type ‘mvn test’ and enter

Now you can see your tests are running and you can see results after tests finishes.

Running wpTrialTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.261 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ————————————————————————
[INFO] ————————————————————————
[INFO] Total time: 17.855s
[INFO] Finished at: Tue Aug 27 13:11:00 EDT 2013
[INFO] Final Memory: 7M/134M
[INFO] ————————————————————————

  1. Integrate with Jenkins

Tests are running fine on local machine using maven build now so its time to move those tests to a continuous integration server.

  • Create a “Build a free-style software project Jenkin Job.
  • Configure newly created job.
  • You can mention your source code using any available version management system[Git, SVN, CVS etc]
  • Also you can run Jenkin job against your local directory.
  • Select ‘Invoke Top-Level Maven-targets’ from Build dropdown box.
  • Enter ‘test’ as Goals
  • Save the configuration.
  • Run the Job


To setup a local working copy as source, you have to run the jenkin Job first without mentioning any source and that build will fail because there is no sources in Jenkins workspace. After first build Jenkin will create a work space for current Job. You can identify that path by checking Jenkins Job Console output. Copy all you data under your project directory to Jenkins workspace and run the Job again. Now you can see tests are running.


This post is only for beginners those who trying to integrate webdriver with Jenkins. There are lot of plugins available on Maven so you can customize you build process as you required.

%d bloggers like this: