Skip to content

This demo repository showcases how to integrate the TestMonitor TestNG Reporter into your Selenium WebDriver test suite.

Notifications You must be signed in to change notification settings

testmonitor/selenium-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

TestMonitor Selenium Demo

This demo repository showcases how to integrate the TestMonitor TestNG Reporter into your Selenium WebDriver test suite. It contains example tests that demonstrate automated test reporting to TestMonitor.

Table of Contents

About

This repository provides a working example of:

  • Setting up Selenium WebDriver with TestNG and the TestMonitor reporter
  • Configuring the reporter in pom.xml and testng.xml
  • Sample test cases using the Page Object Model pattern
  • Automatic screenshot capture on test failures
  • Tests that run on Windows, Linux, and macOS

Installation

Before you start, make sure you have the following installed:

Clone this repository and install the dependencies:

git clone https://github.com/testmonitor/selenium-demo.git
cd selenium-demo
mvn clean install -DskipTests

The project uses Selenium Manager (built into Selenium 4.6+), which automatically downloads and manages the ChromeDriver for your operating system.

Configuration

The reporter is already configured in pom.xml and testng.xml.

First, add the TestMonitor TestNG reporter dependency to your Maven project:

<dependency>
  <groupId>com.testmonitor</groupId>
  <artifactId>testng-reporter</artifactId>
  <version>[1.0.0,)</version>
</dependency>

Next, add the reporter to the listeners section in your test suite XML:

<suite name="Tests">
  <listeners>
    <listener class-name="com.testmonitor.testng.TestNGReporter"/>
  </listeners>
  <!-- test definitions -->
</suite>

Configure your TestMonitor credentials using environment variables or system properties. For this demo, we recommend using -D parameters with Maven:

Configuration options:

Variable Required Description
TESTMONITOR_DOMAIN Yes Your TestMonitor instance domain (e.g., mydomain.testmonitor.com)
TESTMONITOR_TOKEN Yes Your TestMonitor integration token
TESTMONITOR_MILESTONE_ID No ID of an existing milestone to link test results to
TESTMONITOR_MILESTONE_NAME No Name of a milestone (will be created if it doesn't exist or matched if it does)
TESTMONITOR_ATTACHMENT_ON_FAILURE No Attach screenshots on failure (default: true)

To get started, you'll need a token from your TestNG integration. You can find it on the TestNG integration page of your TestMonitor project settings.

Running the Tests

Run the demo tests using Maven with your TestMonitor credentials:

mvn test \
  -DTESTMONITOR_DOMAIN=mydomain.testmonitor.com \
  -DTESTMONITOR_TOKEN=your-token-here

Alternatively, you can set environment variables:

export TESTMONITOR_DOMAIN=mydomain.testmonitor.com
export TESTMONITOR_TOKEN=your-token-here
mvn test

The reporter will automatically:

  • Create a test run in TestMonitor
  • Submit test results (pass/fail status)
  • Include screenshots for failed tests
  • Report test execution times

View results

After running the tests, check your TestMonitor instance to see the reported results.

License

Copyright (c) TestMonitor | we are Cerios B.V. All rights reserved.

About

This demo repository showcases how to integrate the TestMonitor TestNG Reporter into your Selenium WebDriver test suite.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages