top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Running Selenium automation testcases using Jenkins

So far we have run testcases from Maven by using Selenium and TestNG. We also generated Allure reports . Please read this blog for the steps.

But now what If we need to run this using a DevOps tools like Jenkins. What is Jenkins?

Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

Lets try to implement this. This is totally self learned so I am open to more improvements and suggestions :)

I am using the source code management tool like GIT for this purpose.

To begin with we need to push our code into git repository and should have installed Jenkins. You can refer to this link for Jenkins setup

Please ensure Jenkins is up and running in your system.

If you are successful in setting up Jenkins you should be able to see a screen as below:

Sign on into Jenkins using the user and password credentials which you setup.

The main screen will load and you can see this screen


I already have two builds configured but we will see how to create a build from scratch to run testcases.

Click on New Item in the left side menu.


You should see a screen for providing project type settings


Give a name for your build. We are going to run Allure reports and test cases so I have named it as AllureReportDemo and since this is a maven project, we will select project type as Maven project. Click Ok. (If Maven Project is not visible then go to Manage Jenkins on the main menu, then install the Maven plugin)

You will be directed to the configuration section for your build.. There are multiple things you can configure for your build depending on the requirements for your project , for now we will go with just basics for a test case to run. Please go ahead and explore more features to implement.


In General tab, we can provide a description for the build. We will be selecting GitHub project option because we are going to use the project we have in git to run through the Jenkins build. Once the option is selected, you will provided with a textbox to fill in the Project URL . This is nothing but your URL you see in your GitHub web page when you navigate to your repository.


Once you specify that, click on the Source Code Management tab and choose Git

You will prompted to enter the repository URL.


You can find this URL by going to your GitHub repo and clicking on Code button on the right side. You will get a dropdown which will contain the https link . Copy that link and paste it here.


Next step is to check if the branch is correct. My branch is called APITesting. The default branch is always master. You need not do anything if your branch is master. Else you have to specify the branch name as below. You could also click on “? “ to see the ways of writing a branch specifier


Under Additional Behaviors there are a variety of options again we can use them to our discretion depending on the project requirements. For now I am selecting the last one which is Wipe out repository and force clone. Basically this will delete the entire repository which is stored locally by Jenkins and clone the repository from git for every run of the build. This is one way to ensure we have the updated build from Git for each run. But we can also configure Jenkins to run the build every time a commit is being made.


By default the first option is selected, we can remove it and we select the option as mentioned below. Basically this is going to pull from GitHub if a push or a commit is made. For that purpose we can schedule a particular time as well by clicking the Poll SCM option. For now we will manually run the build.


Coming to Pre Build section, we have to provide the path to the POM xml and what's the build supposed to do. I have mentioned as clean install test.

This means that the project will undergo a cleanup and then do a build which will install all the required maven dependencies from POM and then start the test.


In Post Build section, I am not changing anything for now, but feel free to explore all other options. You can also choose the first option if you want the testcases to run only if the build is successful.


Last is Post Build Actions. Here we are going to select Allure Report because our project is going to run testcases and generate reports


Now if you are not able to see this option, it means that you have to install the Allure Report plugin. To do so, follow the below steps.

Go back to the main menu and select Manage Jenkins (Click on Save first!!)

Under System configuration select Manage Plugins


Select the Available tab and search for allure you should be able to see a plugin called Allure Jenkins plugin. Click on install. I have already installed it so I am able to see in under Installed tab.


Once that is installed you can login again into Jenkins as a refresh and then click on your build and select Configure from the left menu. You should be redirected to your configuration page.

Once there you can go to the end and select dropdown and you should be able to see Allure Report as a option.

Configure your allure reports path from your project over here.


That's it we are done with a basic level configuration. Click on Apply and Save and then we should be able to see a screen as below. Note that a link for Allure Report is appearing here.


Click on Back to Dashboard option and you should be able to see the build in the list.


We have created the build . Now lets run the build to see if we are able to execute the test cases and generate allure reports . All you need to do is to click the icon on right end that will trigger a build.

Once you click on it, in the left side bottom you should see it running, #3 means it is running for the 3rd time.


After the execution is complete click on the build name , you should see a screen as below.


Since you installed and ran allure reports you can see a icon for allure report in the page. We can also see the number of times this build has run. Lets try to view logs files. For that click on the last build run.


Here on the left side , click on Console Output to view all the steps executed as part of this build. This is very useful to find out where the build has gone wrong if the build did not run successfully.


You can also view TestResults similar to TestNG by clicking on TestResults link


Now in order to view the allure report, click on the Allure Report link on the page


Great!! we are able to view the same allure report which we see after the test case is executed. And also we see the executors on the right side below is mentioned as Jenkins.

This is a basic flow of steps on how to run a testcase using Jenkins and Git.


Hope this was useful. Happy Automating!!

617 views0 comments

Recent Posts

See All
bottom of page