Automating Defect Logging with Jira and Selenium for algoQA Projects

Modified on Thu, 20 Mar at 1:08 PM

TABLE OF CONTENTS

1. Jira Overview

2. Setting up Jira Software with Your Google Account

3. Creating an API Token for Secure Integration with Jira

4. Integrating Selenium with Jira and logging defects in Jira using algoQA Project

4.1 Prerequisites

4.2 Creating a Jira Ticket when a Selenium test fails. 

1. Jira Overview

Jira is a tool used for bug and issue tracking. It also supports project management features for all kinds of use cases, from requirements and test case management to Agile software development.


Jira is free to use for up to 20 users. However, if any organization requires additional features, such as support, storage, and a large user limit, must choose the commercial version. Since Jira is a bug/issue tracking tool, it enables the assignment, resolution, and implementation of bug life cycle management.


Integrating Jira with your Selenium framework can be helpful for managing issues that occur during automated testing. If a script fails generated by algoQA, Jira can be used to create a defect ticket automatically, which can then be assigned for resolution. This integration helps in the defect management process and ensures that issues are addressed.

2. Setting up Jira Software with Your Google Account

Perform the following:

  1. Enter the URL Products | Atlassian into the browser bar. 
  2. Select Jira Software. In this page, select Get it free button on the right-top corner.
  3. Get started with Jira page appears. Click Google account button to create your account.
  4. Follow the on-screen prompts to create your first project.

3. Creating an API Token for Secure Integration with Jira

To enable secure connections between various software tools or automation scripts and your Jira account, you can create an API token. This token allows these tools to interact with Jira on your behalf without requiring your Jira password. This approach ensures security while facilitating smooth collaboration between different tools.

Perform the following to create an API token in Jira for use in Selenium Jira integration:

  1. Open a web browser and go to your organization's Jira website. For example, if your organization's Jira website is https://example.atlassian.net/, enter this URL in the address bar and press Enter.
  2. Log in to your Jira account using your credentials (username and password).
  3. After logging in, click icon next to your profile and settings icon or username on the top-right corner of the Jira dashboard.
  4. Select  the Account Settings option.
  5. Navigate to the Security tab and then, click Create and manage API tokens link.
  6. In the API Tokens screen, click the Create API token button.
  7. Enter the Label and click Create button.
  8. Upon creating the API token, click Copy button to copy the token to the clipboard and save it to appropriate location.

4. Integrating Selenium with Jira and logging defects in Jira using algoQA Project

Applies to JUnit, Selenium, Maven framework and Java as a programming language 

4.1 Prerequisites

  • Click here to download Eclipse IDE packages.
  • Maven Project must be configured.

4.2 Creating a Jira Ticket when a Selenium test fails.

To automatically create a Jira ticket when a Selenium test fails, and skip ticket creation if the same ticket has already been created in the project, perform the following:

  1. Add required dependencies in pom.xml
    1. In order to Integrate Jira with Selenium, use rcarz Jira-client. This is the wrapper built on top of the Jira Rest API Client. This file enables communication between Selenium and Jira, allowing Selenium tests to interact with Jira's features like creating and updating issues, and querying issue details. 
    2. Scripts generated by algoQA follow structured folder structure. Navigate to pom.xml in the project, and add the following dependency:
    3. Create basic tests using Selenium and Java
    4. In the com.demo.projectpackage, two basic Selenium tests have been created: one designed to pass and one to fail.

      These tests can serve as examples for understanding Selenium test creation and execution.

      Selenium JIRA steps

  2. Create a utility to handle Jira issue
    Custom annotations can be used to mark specific test methods or classes to indicate that they should create Jira issues when certain conditions are met, such as a test failure. This allows you to automate the process of creating Jira issues for failed tests, making it easier to track and manage issues related to your test automation.
    To create a package inside the main folder of your project, for example com.demo.utility create a package to hold the utility classes related to Jira integration as shown.
     
    1. Create the JiraServiceProvider class: This class will handle the creation of Jira issues.
      Code snippet:

    2. Create the JiraCreateIssue annotation: This annotation will be used to mark specific test methods or classes that should create Jira issues.
      Code snippet:

  3. Configure the Hooks File
    In a script generated folder structure, the 'hooks' file contains code that runs before or after scenarios in your test suite. If there is a failure in a scenario, you can use the 'hooks' file to perform certain actions, such as logging the failure, taking screenshots, or notifying team members.

    Project folder structure is displayed similar to the example shown in the following screenshot:
  4. To get the Project Key, perform the following:
    1. Navigate to Projects Main Menu and select View All Projects as follows:
    2. Choose the respective project.
    3. In the Project page, Key will be displayed next to the corresponding project name.
  5. Configure Applications.XML file 
    1. Navigate to the Application Settings. XML file in your script generated folder
    2. Set the Jira Integration parameter to true and add all the required parameters as shown: 

      When you create a JiraServiceProvider object, consider the following parameters:

      Field Description
      JiraUrlIndicates company's Jira URL. If you are working on Jira cloud, then URL will be: https://<organisation>.atlassian.net
      UsernameUser is a parameter used for authentication, but its format can vary based on configuration. For example, format is <Username>@gmail.com
      Password When using Jira Cloud, it is necessary to pass the API Token as the password. Using your login password might not work. For example, the API token could be lorelimpusm12uijk.
      Project KeyThis refers to the project key, which is typically a short, two-letter identifier (e.g., "AS") assigned by Jira. Using the full project name, such as "Algoshack Project," might not work, so it's important to always use the short version.
      Issue Type Indicates the category of an issue. For example, Bug.
      Reporter NameName of the person in the project who is reporting the bug.

  6. Configure the testng.xml file
    After all the required set up, testng.xml file must be configured to run the tests. 
    • Execute your tests
      Upon completing the setup, execute the tests. After test execution, any failures must automatically trigger the creation of a Jira ticket. Results will be visible in the console section for further analysis and verification.

      The following screenshot represents sample console output:


      Successful completion of Selenium tests triggers automatic creation of a Jira Issue, with the console displaying the Issue ID and providing a URL to navigate to the specific issue.

    • Verifying Jira ticket creation
      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 along with a particular test step failure details and Issue details as shown:




      Most of the operations performed through the Jira user interface can be run using the REST API client. The Jira REST API client allows testers to automate the issue tracking and logging process, reducing the need for manual effort and attention.

 


















Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article