Monday, September 2, 2013

WebDriver with Jenkins

In the last post we see how to create Maven Project for WebDriver from eclipse. Now let's configure same Webdriver Maven Project on Jenkins.

Setup Jenkins on Windows 

download the jenkins from following location
http://jenkins-ci.org/
Running Jenkins as War file 
You can run jenkins using war file, if you are doing it you don't need any slave to start on machine. Running Jenkins as Windows Service 
If you have installed Jenkins as Windows Services then you need to Start Slave and Bind you project to that slave.

Create/Run Slave Node 

If Jenkins is installed as Windows Services you need to start the JNLP slave node on machine where you need to execute your test cases. Follow the process to create node.
  • Go to Manage Jenkins->Manage Nodes and Click on New Node
  • Enter the Node Name and choose Dumb Slave
    Create Jenkins Slave node for WebDriver Execution
    Create Jenkins Slave node for WebDriver Execution


  • Enter the information as mention in the screenshot
    Configure Node for WebDriver
    Configure Node for WebDriver
  • After saving node will be listed under Nodes 
    All Available Nodes in Jenkins
    All Available Nodes in Jenkins
  • Start the node by Running displayed command in CMD
    Start JNLP node in Jenkins
    Starting JNLP Node in Jenkins
  • if everything has been done correctly if you will able to see small java program running
    Connected JNLP Node
    Connected JNLP Node


Configure Maven in Jenkins

Before you create a new Job for Maven WebDriver Project, let's configure Maven in jenkins
Go to Manage Jenkins->Configure System and Provide Installation directory for JDK and Maven as mention in screenshot below
Configure JDK and Maven in Jenkins
Configure JDK and Maven in Jenkins

Create New Job on Jenkins

Now let's create the new Job for Project
  • Go to Home page and click on New Job
    Create Jenkins Job for Maven WebDriver Project
    Create Jenkins Job for Maven WebDriver Project
  • Restrict the job to run on the Slave Node we created
    Configure WebDriver Project to run on Specific Node
    Configure WebDriver Project to run on Specific Node
  • Click on Use custom workspace and Mention your workspace location und Directory
  • Provide the path of pom.xml in Root POM and provide Test in Goals and Options
    Provide Maven in Goal in Jenkins
    Provide Maven Goal in Jenkins

2 comments:

KALYAN CHERUKURI said...

Hi Gaurang,
Could you please explain the advantage of jenkins integration with webdriver

Krish Murthy said...

How to make Jenkins build fail, when selenium reports back "no such element"
I am currently running some Selenium Webdriver scripts on my build pipeline in Jenkins. Say for example, I have a script line which clicks on the Login button. Due to some change the login button's xpath as changed. Though my scripts stops stating "no such element" - the CI tool Jenkins reports back stating "BUILD SUCCESS". Is there a way to make it fail instantly? If so how to do it?

Post a Comment