Have you ever seen Jenkins with selenium? Welcome to Jenkins post we have seen so many things in the last post about maven integration and GitHub integration now let us create a build and run through Jenkins. Before moving to integration, part let’s have a short intro about Jenkins

 

Selenium with Jenkins Integration

Jenkins with Maven and Selenium

What is Jenkins

  • Jenkins is an open source continuous integration tool which is written in Java
  • Jenkins was originally developed as the Hudson project. So if you ever see Hudson then it will be known as Jenkins CI Tool. Hudson’s creation started in summer of 2004 at Sun Microsystems. It was first released in java.net in Feb. 2005.

Know more about Jenkins

 

Jenkins with Selenium

  • When your test cases are ready and you want to handover to the client or manual testing team so that they can trigger these test cases using single click then Jenkins is the best choice.
  • Using Jenkins we can create a build (Build – set of Test case combined together) and we can run easily using a batch file or Git or build.xml or SVN etc.
  • In Jenkins, we can schedule the build periodically

Example- You want to run 100 Test case daily at 10 pm then Jenkins will take care      of this based on our pattern it will trigger your build

  • Email-Notification- Jenkins provide notification emails to once build passed or failed to respective recipients (Depends on t configuration)

Before starting if you have been having Eclipse , TestNG and if you are using Excel sheets or CSV then these jars should be ready.

 

We will divide full tutorial into the following section.

1- Download Jenkins (War file)

2- Configure Jenkins for Running Build (Configure Java,Email notification)

3- Execute Selenium build using Jenkins (Using batch command)

4- Schedule Jobs in Jenkins to run periodically using cron pattern.

We can integrate Jenkins with Selenium, Maven, Git, Github and other tools we can like Sahi, Telerik etc.

So lets start Jenkins Integration with Selenium

 

 

113 thoughts on “Complete Guide to Setup and Configure Jenkins with Selenium

  1. RANJAN V says:

    Hi Mukesh,

    How to Run Automation Scripts in Jenkins based on Cron Expression Pattern?

      1. RANJAN V says:

        Thanka a lot)))

  2. Hariprakash says:

    Hi Mukesh, How to update Pass/Fail results for testcases in Jira through Jenkins. I am testing Web based application, Jenkins job has to run and it should update the result as Pass / Fail in Jira automatically and also i want to update the reports with screenshots in Jira.

    1. Hi Hari,

      For this, you need to go through JIRA APIs’ which will describe about how to call update status from you selenium script.

  3. madhu says:

    Hi Mukesh,

    We are executing the scripts through jenkins , jenkins will take latest code from github.
    here my problem is jenking is connecting github but it is saying “Repository not found.” and returned status code 128.

    1. Hi Madhu,

      Did you check through which user in Jenkins, the code is getting cloned? Moreover, login to the corresponding machine (where you want to clone code), do ssh to github and check the status of command.

  4. vimal says:

    Hai Mukesh
    can you guide me how to set run testcases in particular time using jenkins

    1. Hi Vimal,

      Under Build Triggers, you will be able to see Build Periodically, there you need to set cron job pattern. For CRON job, check this link https://en.wikipedia.org/wiki/Cron

  5. Karthik says:

    Hi Mukesh,

    Great job! Helping the QA Community with your knowledge sharing post/videos.

    Can you please let me know how we can pull our latest code from Tortoise SVN to Jenkins,so that the automation scripts we run will be updated each time.

    1. Hi Karthik,

      You can define SVN details under ‘Source Code Management’ header followed by selection of Subversion option.

  6. Siddhartha says:

    Hi Mukesh,
    How can I see the UI (i.e Browser opening) while executing Selenium files using Jenkins.

    1. Hi Siddharth,

      If your Jenkins slave is master or another which is not connected through Launch slave agents via Java Web Start then all scripts will run in headless mode. So I would recommend you to connect slave through Java WebStart way. Also refer this link https://wiki.jenkins.io/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines+on+Windows

  7. RAJENDRA Narayan Mahapatra says:

    Hi Mukesh, could you please show Jenkins configuration with latest version of Jenkins? As the UI has completely got changed.

    1. Hi Rajendra,

      As per my observation, UI is almost same only the way of organisation of various features are now categorized.
      I am also planning to post for new Jenkins. I ‘ll do it soon…:)

  8. RAJENDRA Narayan Mahapatra says:

    Hi Mukesh,

    Can you please show the steps for configuring extent report and html report (TestNg) in Jenkins? It will be very useful…..

  9. Shiva says:

    Hi Mukesh,

    Your way of teaching and your videos are awesome. Really it is helping a lot for many guys like me. keep up the Good work. Hats of to you..!!

    Thanks
    Shiva

    1. Hi Shiva,

      Your comments made my day…I’ll always try my level to solve doubts and queries of blog subscribers.
      Very very thanks Shiva…:)

  10. Mallik says:

    Hi mukesh This is Mallikarjun…Iam learning alot from YOur Videos.Your Videos are very simple and understandable for everyone..It helps alot for all the Automation learners.Thank you very much Mukes..Please keep sharing your fabulous work like this…

    1. Hi Mallik,

      Very very thanks for your appreciation…:)
      Feel free to ask your doubts in my blog, I’ll try my level best to answer your queries.

  11. Harikrishna says:

    Hi Mukesh,
    Can i use TFS instead of Jenkins? If yes could you please explain briefly?

    1. Hi Hari,

      Yes, you can because TFS is a proprietary tool which has all features for a version controlling, build dependency, CI/CD environment. But sorry to say that I never worked with this tool so can’t say anything about its configuration part.

  12. Ramyashree Bhat says:

    Hi Mukesh, how can we do Jenkins-Extent report integration? I guess we need to use HTML Publisher plugin for that… But I’m struggling with the configuration ..could you please help?

  13. jino says:

    Using Jenkins , the code is running in our local machine..Right?……Can we done in a Cloud

    1. Hi Jino,

      Yes, you can connect/configure jenkins with cloud based machine also.

  14. Balaji says:

    Hi Mukesh
    JDK option is not available in configuration of jenkin……….
    can i execute my test case without configuration

    1. Hi Balaji,

      You need to provide JDK path in jenkins otherwise jenkins can’t find it.

      1. Pranay Agarwal says:

        Hi Balaji,
        You can find JDK option in Manage Jenkins –> Global Tool Configuration

  15. Anji says:

    Jenkins job is failing with message like “run.bat” is not a recognized as a interal or external command, operable program or batch file… then exit 9009…. Any idea on how to resolve

    1. Hi Anji,

      Have you restarted your machine after setting path for Apache Maven.
      After restart, if issue is still same then install Maven 3.1.1 and restart machine followed by mvn command execution.

  16. Sumeet Kumar says:

    Hello Sir,
    I need your help on this,
    how to find out spelling mistakes by using selenium in any website is there any way?????

    1. Hi Sumeet,

      Use assertions for comparing characters in a string.

  17. snehal says:

    Hi Mukesh,
    Would you pls help me on this?
    I have tried so0 many times installing testNG add-on through eclipse marketplace, but everytime i get this msg
    “Unable to connect to repository http://beust.com/eclipse/content.xml
    Connection timed out: connect”
    I m using latest Eclipse-oxygen version.
    can you pls help with other ways to installing it?

    1. Hi Snehal,

      Yesterday also, I installed testng into my new eclipse instance from marketplace. The issue which you are facing might comes in organisational network due to which network firewall doesn’t allow unsigned applications to get install in machine or network connectivity issues.

      1. snehal says:

        Oh ok, hmm yeah i agree with you of firewall – unsigned issue..that might be the case. But hey, i found a way around and its successfully running TestNG.
        thanx for your instant reply and all your videos are great and makes selenium easy to learn.

        1. Hi Snehal,

          That’s great..:)
          May I know, how you solved it…

          1. Rajesh Thakur says:

            I also did little R&D and got the new way to install TestNG.

            Download separate TestNG jar files. and integrate them with eclipse’s.
            Once you download the Jar files, extract the zip file. It will contain two folder (Feature and plugin) each containing 2 jar files. Add those jar files in eclipse’s feature and plugin folder respectively. Restart eclipse.

          2. Hi Rajesh,

            Very very thanks for sharing this info. This will surely help other readers also.

  18. Surendar says:

    Hi Mukesh,
    what is the best tool to test rest API’s?

  19. Arvinder says:

    Hi Mukesh,
    Thanks a lot for sharing knowledge. Can you please upload more videos on Jenkins showing different features of Jenkins.

    1. Hi Arvinder,

      I’ll do it soon…:)

  20. krishna says:

    Hi Mukesh,
    Thank you so much for valuable information you have shared so far and i have managed to learn a lot from you videos.
    please can you assist me with regards to the below

    i am able to generate cucumber reports and able to send them through jenkins successfully, but the issue that i am facing is with the cucumber reports.
    The reports that i am receiving are in plain text and graphs are missing.
    i have updated the content type to “Both HTML and Plain Text” under Editable Email notification section.
    kindly can you suggest me if i am missing any other settings

    1. Hi Krishna,

      Is it broken CSS on report ?

      1. Krishna says:

        Hi Mukesh,
        Please execuse my ignorance,
        I am very new to Jenkins. I did not understand your question.

      2. Krishna says:

        Hi Mukesh
        Yes it looks like broken CSS on the email, as I can see the cucumber reports getting successfully generated under the build folders but the same report when I am sending via Jenkins, I am missing the formats in the mail which i am receiving(graphs, colours )

        Regards
        Krishna

        1. Hi Krishna,

          There is no such setting to fix CSS broken issue. Have you tried Extent Report V3?

          1. Krishna says:

            Hi Mukesh
            Thank you so much for the messge
            Please can you let me know where can I find the detials of Extent Report v3.
            Or can you please advise me on the below

            Is it possible to send cucumber reports as an attachment via Jenkins, as the cucumber reports are getting generated in build folder.

            Kindly can you guide me please

            Regards
            Krishna

          2. Hi Krishna,

            For Extent Report V3, you can go through this link http://extentreports.com/docs/versions/3/java/
            yes, it is possible, you can take report link from Jenkins jobs’ workspace

  21. surya ramtej says:

    hi Mukesh,
    Iam new to Jenkins. as i am using the codebeamer for manualtesting and i would like to learn the automated testing and integrate the codebeamer with selenium via jenkins. i have very less programming language in Jenkins. So can you help me with the following queries. Looking forward for your reply.
    Regards,
    Surya

    1. Hi Surya,

      As per my observation, codebeamer is a proprietary ALM tool for which I don’t have any license. So as of now, it is not possible me but I’ve added this into my wishlist.

  22. Anoop sharma says:

    Hi Mukesh
    I need your help regarding parameterized build creation from jenkins.
    I want to upload file (.xlxs) from jenkins , which i done, but now how can i use this in our code. i need to take input from this xls file and take action accordingly.
    i declare path of this file in constant.java file and i used it in my logic. please help me out.

    1. Hi Anoop,

      If you are able to get path of excel file then read/write operation is not tedious job. Please check this link https://vistasadprojects.com/mukeshotwani-blogs-v2/read-and-write-excel-files-in-selenium/

  23. bharath says:

    Hi Mukesh ,

    i am new to jenkins , is it required to set up jdk in jenkins and i will be using git . i give me selenium project path as the repository and also give the path of the pom .
    is there any thing else i need to configure

    1. Hi Bharath,

      JDK is used to compile your java files which comes as bundled with jre. Git will help you to bring latest code from repo.

  24. Pranav Pund says:

    Hi Mukesh,
    Could you please explain us what set up we need to do in Jenkins if we need our test to be triggered automatically once developer checks in code in SVN? In your video you have shown how to run our Automated tests at particular time using CRON Pattern, but it would be really helpful if you could explain us what set up we need to do in Jenkins if we need our test to be triggered automatically once developer checks in code in SVN?

    1. Hi Pranav,

      For SVN, there is a plugin being mentioned on this link https://wiki.jenkins.io/display/JENKINS/Subversion+Plugin
      This page contains configuration for polling to svn repo.

  25. Anoop shrama says:

    Hi Mukesh
    I want to run my java code (selenium script ) via jenkins , and jenkins is setup on iOS. so can you telll me how can i run my script via jenkins. i am not using Test NG so no XML are there.

    1. Hi Anoop,

      In this case, you java file should have main method. On Mac, you execute your code via Execute Shell section inside jenkins job configuration via navigate to required folder then javac filename.java followed by java filename…thats it.

      1. Anoop sharma says:

        Thanks for reply , yes i have main method in my DriverScript.java file, but i dont have too much knowledge about Jenkins , can you let me know in detail how can i create Shell executable and configure in jenkins ,or it would be good if you give me any reference so i can set up my project and test it, if all goes well i ll deploy on my server.

        1. Hi Anoop,

          Check this link

  26. palanisamy says:

    hi, mukesh how to do api testing using selenium with java in automation.

    1. Hi Palanisamy,

      Selenium itself is an API which allows us to interact with Web page controls. And Selenium deals only with controls of web page.

  27. Harikrishna says:

    Hi Mukesh,
    Can you please explain about MAVEN AND GITHUB Briefly?
    and also explain the difference between MAVEN AND GITHUB and JENKINS Briefly?

    1. Hi Harikrishna,

      In brief….
      Maven is build dependency(to fetch dependency and adding those to project build path)
      GitHub is for code repository(to secure your source code to some location)
      Jenkins is for execution(to execute your script at particular time based CI/CD strategy defined by project)

      1. harikrishna says:

        Thanks Mukesh

        1. Harikrishna says:

          what is the difference between Implicit Wait and Explicit Wait and Fluent wait?
          If possible can u plz explain the above with sample code?

      2. Harikrishna says:

        Thnx

  28. Gaurav says:

    Hello Mukesh,

    Thanks for sharing in depth of Jenkins knowledge and setup.
    I have a question : Why we should use Jenkins in Selenium.
    I am able to run my Test through TestNG by simple doing rightClick on TestCase.
    Just for a minute forget about email notification advantage , Then i am not able to figure out the main use in selenium.
    Generally in our organization we are updating code on local machine and then we use to checkin through SVN. So this question is always hitting me why to use Jenkins.
    I have gone through various websites to find this answer but did not get satisfactory answer.

    1. Hi Gaurav,

      As you told that you are executing your script by yourself that means everytime script execution requires human intervention. Now think about a situation, when you want to trigger hundreds of scripts at particular time of day so that by end of day you can see results of execution. This is where, Jenkins plays its role….
      Jenkins can execute scripts at given time. It will fetch latest code from SVN and then it can execute latest code. This is just an intro for a jenkins wrt your usage. If you look at broader level then jenkins plays an major role in Continuous Integration/Continuous Delivery scenario.

  29. Nigam says:

    Hi Mukesh, My jenkins runs in linux box and my testing team wants to run selenium test in real browser. How do I set up this? Do I need to create a new Windows Slave and run selenium Tests there? Please advise…

    1. Hi Nigam,

      If your script is being created for linux environment(here environment is referring to driver executables which differs for linux & windows) then run it on same machine where Jenkins has been hosted. If scripts are for windows environment then connect a windows slave to jenkins and execute script on slave itself.

      1. Nigam says:

        Hi Mukesh- Currently my slave is running as windows service, and I guess that is blocking selenium to launch chrome browser. I can see that chrome.exe and chromedriver.exe has launched in the background(from task manager) though. How do I handle this?

        1. Hi Nigam,

          This is jenkins usual behavior. If slave is running as windows service then web browser tests always run in headless mode. But in headless mode, it runs well. And if you want to see execution by your eyes then don’t configure slave as Windows service.

  30. Bala says:

    Hi Mukesh,

    I am getting an error “Firefox can’t establish a connection to the server at localhost:8080”. How do I proceed with this? Could you please help me out at earliest?

    1. Hi Bala,

      Please tell me which version of FF, GeckoDriver, Selenium are you using?

  31. tribhuvan says:

    Hi Mukesh,

    I want to use Selenium With Cucumber for writing my test scripts. Can I use the Jenkin in this case. As per your demo , you use the TestNG . is there any possibility use the jenkin in my case as well.

    1. Hi Tribhuvan,

      Jenkins is CI/Cd integration tool. It help you to execute your test script with given parameters in remote machine without human intervention. Jenkins is capable of doing lot of other stuffs too.
      And remember, Jenkins is nowhere related to TestNG. You can use Jenkins at anywhere.

  32. nataraja k b says:

    Hi Mukesh this is Nataraj. i am trying run localhost:8080. bur it asking for Username and password? may i know how to get username and password?

    1. Hi Nataraj,

      Go to .jenkins folder in Users folder then open config.xml. Look for useSecurity tag and make its value as false. Exit cmd of jenkins and rerun it.

      1. nataraja k b says:

        Thank you Mukesh……..

  33. Nithya says:

    Hi Mukesh, I have invoked jenkins using the command “java -jar jenkins.war”. Still, Selenium scripts are running in headless browser. Plz tell me how to execute the testscripts using chrome browser through jenkins. Thanks in Advance!

    1. Hi Nithya,

      By default, execution runs of master node itself and that too in headless mode only. If you want to see execution then create a new node from Manage Nodes option. Point newly created node to same machine i.e the machine where Jenkins server has been hosted.

  34. Nagendra says:

    I’m getting below error in WEB after typing localhost:8080

    Unlock Jenkins
    To ensure Jenkins is securely set up by the administrator, a password has been written to the log (not sure where to find it?) and this file on the server:

    C:\Users\Deepa\.jenkins\secrets\initialAdminPassword

    Please copy the password from either location and paste it below.

    Administrator password

    ——————————–
    If i go to that path im not able open that file because it is a KEY file

    1. Hi Nagendra,

      Open it with Notepad

  35. Asmita says:

    Hello Mukesh,
    I have tried below code
    java -jar jenkins.war
    it’s not work
    thought may be port 8080 is occupied so tried below
    java -jar jenkins.war -httpport=8081
    still same error
    please help me to solve this problem.

    [0mMar 25, 2017 11:00:40 PM jenkins.model.Jenkins$21 onAttained
    INFO: Completed termination
    Mar 25, 2017 11:00:40 PM jenkins.model.Jenkins _cleanUpDisconnectComputers
    INFO: Starting node disconnection
    Mar 25, 2017 11:00:40 PM jenkins.model.Jenkins _cleanUpShutdownPluginManager
    INFO: Stopping plugin manager
    Mar 25, 2017 11:00:40 PM jenkins.model.Jenkins _cleanUpPersistQueue
    INFO: Persisting build queue
    Mar 25, 2017 11:00:41 PM jenkins.model.Jenkins cleanUp
    INFO: Jenkins stopped

    1. Hi Asmita,

      If you are using windows environment then try this installer

      1. Asmita says:

        please help me.
        It’s not working.
        what’s problem with cmd??

        1. Hi Asmita,
          Installer link which I sent was a workaround only if you are running with shortage of time. Use netstat -a in cmd and check which port is free

          1. Asmita says:

            It shows status Listening
            What should I do?
            Thanks for your reply

          2. Hi Asmita,

            Try to install jenkins with free port number.

  36. sumanth says:

    Hi mukesh, I ‘ve configured Jenkins in my PC earlier. So forgotten my USER ID: tried couple of ways to find it. But unable to get the user id. can you help me out?

    1. Hi Sumanth,

      Navigate to folder users-> login user folder-> .jenkins , the open config.xml and set false value against tag. Close cmd and again run java -jar jenkins.war

      If you have installed it as windows service then navigate to jenkins installation folder and edit config.xml in same way which I’ve mentioned above.

  37. Sankalp varadkar says:

    logger.log(LogStatus.FAIL, “Title Verification”, image); } report.endTest(logger); report.flush();

    1. Hi Sankalp,

      Use this -> logger.log(LogStatus.FAIL, image);}
      report.endTest(logger);
      report.flush();

  38. Ashwini says:

    Hi Mukesh ,

    I have downloaded jenkin war file, when i open the jenkin configuration i don’t see fields of jdk and maven configuration on localhost:8080.
    How should i rectify this.

    1. Hi Ashwini,

      If it is Jenkins 2.xxx then check settings under Global Tool Configurations.

  39. Sindhu says:

    Hi Mukesh,

    I configured a job in Jenkins and in the Build i gave the .bat files details in Execute windows batch section. While triggering the build i could see the execution output in the console , but i could’nt see any browser opening.

    I have done the jenkins setup using .msi file.

    What should i do to see the gui of the browsers?
    Thank you

    1. Hi Sindhu,

      If you are running Jenkins slave as service then you won’t be able to see execution. Run on slave machine as JavaWebStart

  40. Shruti says:

    Hi Mukesh,
    I have downloaded latest jenkin file from the website. After download, it asked me to install preferred plugins or customized plugins. I went with automatic i.e mainly preferred plugins.
    But the problem is I am enable to see JDK configuration in configuration system of manage jenkins tab. Please help

    1. HI Shruti,

      You can find in Global tool configuration.

  41. lokesh says:

    I am unable to configure emails in Jenkins

  42. amit says:

    Nice man I saw your selenium video , its very helpful , thanks a lots for sharing such a valuable knowledge

    1. Thank you AMit. Keep in touch.

  43. Chitra says:

    Hi Mukesh, I downloaded Jenkins 2.19.1 in windows 10 and executed cmd : java -jar C:/Jenkins.war

    But I get below error saying Jenkins is stopped:
    Can you please help me on what I need to do for Jenkins to work. Thanks in advance
    webroot: $user.home/.jenkins

    Oct 17, 2016 11:40:49 AM org.eclipse.jetty.util.log.JavaUtilLog info
    INFO: Logging initialized @602ms
    Oct 17, 2016 11:40:49 AM winstone.Logger logInternal
    INFO: Beginning extraction from war file
    Oct 17, 2016 11:40:52 AM org.eclipse.jetty.util.log.JavaUtilLog warn
    WARNING: Empty contextPath
    Oct 17, 2016 11:40:52 AM org.eclipse.jetty.util.log.JavaUtilLog info
    INFO: jetty-9.2.z-SNAPSHOT
    Oct 17, 2016 11:40:54 AM jenkins.model.Jenkins _cleanUpShutdownPluginManager
    INFO: Stopping plugin manager
    Oct 17, 2016 11:40:54 AM jenkins.model.Jenkins _cleanUpPersistQueue
    INFO: Persisting build queue
    Oct 17, 2016 11:40:54 AM jenkins.model.Jenkins cleanUp
    INFO: Jenkins stopped

    1. Hi Chitra,

      In your system 8080 port is occupied. Kindly start the Jenkins in other port

      java -jar jenkins.war –httpPort=8081

      1. Chitra says:

        Thanks Mukesh, it worked

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.