Integrating Selenium

Store your test automation results in TestMonitor, alongside your manual tests, to get an overview of all your test efforts in a single place.

By integrating Selenium with TestMonitor you can keep all of your testing results in one place. Selenium allows you to automate tests, and by integrating it with TestMonitor you can also automatically record those test results. By tying Selenium’s automated tests with TestMonitor you can take advantage of features like risks and requirements while keeping all your data in one place for reporting and issue management.

How It Works

The integration with Selenium uses the TestNG framework. A listener is used so that every test result of every test case will automatically be sent to TestMonitor with no need to change any any of your Selenium test code. 

Your test cases will be created in TestMonitor. Previously created test cases will be recognized by name and re-used, avoiding test case duplication. They are planned in a run and the test results will be stored.

Software Requirements

When you are integrating your Selenium tests in TestMonitor, we recommend to meet the following software requirements:
  • Java 8 or newer
  • Maven 3 or newer
  • Selenium 3
  • TestNG

Generate an API Token

Before you integrate the TestMonitor API client in your test code, you’re going to need valid API credentials. To create an API token in TestMonitor:
  1. In the top menu, click the circle containing your avatar or initials and select My account
  2. Scroll down to Personal Access Tokens and click the Create token button. 
  3. Choose a name for your token and click Create. Your token will appear in the popup.
  4. Copy the personal access token immediately, it will not be available to view later.

Integrating the TestMonitor Client and Listener

After you’ve created your token, it’s time for the next step in the process. Follow the directions below to integrate TestMonitor with the listener:
  1. Integrate the TM client in your test code. 
  2. Set up the TestNG listener and configure it to send data to your TM account. We’ve created a step-by-step guide on our GitHub page to get you started.
  3. Optionally, by implementing the HasWebdriver interface, Selenium test results will be annotated with a screenshot when test cases fail.

If you want to see the client in action in a different project, take a look at our example Selenium project

Using the Integration

When everything is in place, you’re ready to run your Selenium test. Once started, the following actions will take place:
  1. The test cases will be executed.
  2. The TestNG listener will be triggered.
When you run a Selenium test, the listener will:
  1. Create a test suite with test cases in TestMonitor. When a test case already exists, it will be re-used.
  2. Create a new milestone in TestMonitor, or reuse it when it already exists.
  3. Create a new test run.
    1. Assign the test cases.
    2. Assign itself to the test run.
  4. Store test results for each test case in the run.
    1. When the test case passes, the test result category will be set to Passed.
    2. When the test case fails, the test result category will be set to Failed and a description of the error and screenshot will be included.

You can assign your test cases to requirements, risks, and applications. Once the test results have been stored, you can track them and link issues when needed. You can use the reports to analyze which test cases pass and fail, and where potential bottlenecks are.