How to Integrate Selenium tests with Jira?

6 MIN READ

Streamlining Bug Creation For Automation Test Cases

In the last few decades, the IT sector has rapidly upgraded many approaches and processes, yet SDLC remains the same. One prominent example is the Jira integration with Selenium, it can effortlessly revolutionize the test management process. Undoubtedly Jira and Selenium are holistic approaches if you are a tester, they make data migration effortless.

Integrating Selenium with Jira will provide improved visibility and traceability that can save time and effort in the best way possible. It can benefit you from automatic creation, updating, and merging of Jira issues as per Selenium test results. By leveraging Jira test case management tool, the user can easily track history and monitor the status of test cases, and bugs.

How to integrate selenium tests with jira

In addition, comprehensive reports and dashboards that demonstrate the relationship between project requirements and their execution help in transparent communication with teams.
Let us explore how to integrate Selenium with Jira for great efficiency, effectiveness, and accurate results.

How To Create API Token in Jira

Creating API tokens in Jira is an easy process, following are the steps:

  1. Open Atlassian Jira software and Sign in/ Sign up to create your profile.
  2. Login or open your profile from the Menu.
  3. Click on the Manage Account option.
manage account
4. Navigate to Security and click on Create and Manage API tokens.
Navigate to security and click on create and manage API tokens
5. Click on Create an API token.
Create an API token
6. Click on Lable, give any memorable name, and click on Create.
7. Before closing the dialog, make sure to click on copy to clipboard and save it in the desired location.
API keys and tokens both are prominently used for permission and verification. These two may seem similar as they both work as credentials to access APIs but, they serve different purposes. Before moving forward, let’s be clear about the difference between the API key and the API Token.
The API token is generated by the service provider, it is a set of unique codes that feature user-specific information. It is used as a credential to authenticate the application to access API. Tokens can be used for a limited period of time, these are considered more flexible in managing access and enhancing security.
An API key is programmatically used which contains a large string of numbers or letters. An API key is secured for server-to-server communication. Most of them are static and can be configured with specific permissions or access levels.

How To Connect Selenium With Jira and Log Defects in Jira Using Selenium

Let’s start connecting Selenium with Jira logs, it enables seamless integration of Selenium with Jira to identify defects and issues. The process starts with the prerequisites and ensures Eclipse IDE and Maven project setup are already installed.
How To connect selenium with jira and log defects in jira using selenium
The next is to navigate pom.xml and check for dependencies or else we will be adding them as shown in the image below:
The next is to navigate pom.xml and check for dependencies or else we will be adding them

Step 1. Create Basic Tests Using Selenium and Java.

We will create two basic test cases under the package com.mystore.testcases and place them in the desired location. The condition is that one test case must pass and one must fail.
Create basic tests using selenium and java.

Step 2. Create a Utility To Handle the Jira Issue.

Let’s create the package inside the main folder com.mystore.utilities where two test cases will be stored.

  1. Jira Service Provider: This class will have a method to create a Jira issue.
  2. JiraCreateIssue: This contains a custom annotation code.

Step 3. Create Listeners To Notify Test Failures.

If we create a listener so that each time a test fails, it automatically creates the Jira issue method. This listener keeps track of test failures and executes specified code.
This example names the listener as TestListener.java, created inside the package com.mystore.utilities.

Step 4: How To Get Project Key in Jira.

  • a) Navigate to Jira URL (https://example.atlassian.net)
  • b) Click on the Projects Menu
  • c) Click on View All Projects
  • d) Choose the Desired Project
  • e) Navigate the Project Page, and click on Project Settings
  • f) Look for the field Key. This is the short project Key
  • g) Just copy and use it as a project key
To authenticate with Jira API, you need to add Jira credentials to your Selenium test scripts. When creating a Jira service provider objective, remember the following pointer mentioned-
Jira URL: This should be a company URL, if someone is using Jira it should be something like: https://xyz.atlassian.net
Username: This parameter is the login name (typically email) but depends on the configuration (ex: [email protected])
Password: if using Jira cloud, one must pass the API Token as a password. Using one’s login password might not work (example: API token lorelimpusm12uijk).
Project: This is the project key, often named with two letters (ex: BS). Using the full project name like the BrowserStack project might not work, so always use the short version.

Step 5. Configure the testng.xml File.

Once we have all the required set-up, we need to have a testng.xml file configured to run our tests. Our sample XML file looks like below. (You can use your existing testng.xml file to run your tests).
Configure the testng.xml file

Step 6: Execute Your Tests.

We can execute the tests once the setup is complete. Once tests are executed, any failures should automatically create a Jira ticket. After execution, view the result in the console.
As the failure occurred, on the Console we can clearly see the ticket in Jira as shown in the image below:
Execute your tests

Step 7: Ensure the Ticket Is Created in Jira.

In the final step, we will need to navigate to the Jira dashboard to check whether an issue has been created or not. In the Jira dashboard, click on the project dashboard to see if a new issue has been created, the example is shown below:
Ensure the ticket is created in jira
Integrating Selenium tests with Jira offers a powerful toolset and systematic approach to software testing. By automating the problem tracking and logging process, testers may save manual work by using the Jira REST API client.
The Jira REST API client may be used to execute the majority of tasks available through the Jira user interface. Every developer and tester has serious concerns about device fragmentation because, for accuracy, all websites must function flawlessly across various devices, browsers, and operating systems.
We take pride in our dedicated team of seasoned QA engineers at MoreYeahs with notable industry expertise known for catering QA solutions to your requirements. Moreyeahs helps you meet the highest standards of software quality and performance.
To know more – Let’s Connect.
Related Article: