Pages

Running Selenium Cucumber Tests in Jenkins

This article shows how to configure and run Selenium (+ Cucumber) Tests in Jenkins. Before we dive into more details we have to have Jenkins installed in a server. Here is a quick way to setup Jenkins in a linux server.

OK all done, lets go though with the steps,

Step 1
First you need to install google chrome. This is called as chrome in headless mode. Because you really can't see the chrome window when you are running tests in Jenkins.

 wget -qO - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -  
 sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'  
 sudo apt-get update  
 sudo apt-get install google-chrome-stable  

Step 2
Then install xvfb. OK what is this xvfb ?
Based on Wikipedia,

Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output. From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary.


 sudo apt-get install xvfb  

Then start xvfb
 Xvfb :1 -screen 5 1024x768x8 &  


Step 3
OK , server changes are done. Now its time to move into Jenkins configurations.

First Install this plugin, (Jenkins -> Manage Jenkins --> Manage Plugins)
https://wiki.jenkins-ci.org/display/JENKINS/Cucumber+Reports+Plugin

Why do you we need this ?
This plugin allows Jenkins to show Selenium + cucumber results as a graph with screenshots.

So in order to generate graphs this plugin need the report.json file that generated from Selenium + cucumber.

 @RunWith(Cucumber.class)  
 @Cucumber.Options(glue = {"classpath:com/rd/uat"}, strict = true, format = {  
     "pretty", "html:target/cukes", "json:target/cukes/report.json", "junit:target/cukes/junit.xml"})  
 public class RunCukes {  
 }  


Here is the plugin configuration in Jenkins.
Create Jenkins Job --> Then add this as "Post build Step"


Step 4
Add following environment variable to Jenkins. (Jenkins --> Manage Jenkins --> Configure System)

 DISPLAY=:1.5  

OK We just configure Jenkins to run selenium and Cucumber Tests.
Now run the Jenkins job and check the cucumber reports. :)
Here are some sample reports,



14 comments:

  1. In the provided information i agree our all information and really very nice all articles ,thanks for sharing in this post.
    I like in this post.
    php training in chennai

    ReplyDelete
  2. Hai,

    Nicely written post. I am just about to start a new blog and there could not have been a better guide than this one for some good pointers. I am looking forward to starting a successful blog after reading this incredibly useful post of yours. Waiting for more such posts like this.

    Keep writing and sharing!

    – Rithika

    SEO Training in Chennai

    ReplyDelete
  3. This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..
    Peridot Systems Adyar Complaints

    ReplyDelete
  4. the blog is very interesting and will be much useful for us. thank you for sharing the blog with us. please keep on updating.
    Informatica Training in Chennai Adyar

    ReplyDelete
  5. this is really too useful and have more ideas from yours. keep sharing many techniques. eagerly waiting for your new blog and useful information. keep doing more.
    Digital Marketing Services in Chennai

    ReplyDelete
  6. thank you for sharing such a great blog with us. expecting for your updation.
    Android training in chennai

    ReplyDelete
  7. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
    Digital Marketing Company in India

    ReplyDelete
  8. Thank you for sharing such a nice and interesting blog with us. Hope it might be much useful for us. keep on updating...!!
    seo company in india
    digital marketing company in india

    ReplyDelete
  9. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Java Training in Chennai

    ReplyDelete
  10. Interesting blog about running selenium cucumber test which attracted me more.Spend a worthful time.keep updating more.
    MSBI Training in Chennai

    ReplyDelete
  11. Nice Information Regarding Selenium Cucumber Tests in Jenkins My sincere thanks for sharing this post Please Continue to share this post
    Selenium Training in Chennai

    ReplyDelete
  12. Thanks Admin Amazing Post Keep UpDate.Thank You.

    Top 10 Most Popular Internet Marketing Tools,Black Hat Vip Seo Software,Website Seo Backlinks Software,Website Traffic Bot Software.Etc Free Download Online Please Visit Our Website

    http://best-premium-seo-tools.blogspot.com

    ReplyDelete