Run your Selenium tests with TestNG and open the generated index.html. A direct TestNG run writes that file, plus linked HTML and text result files, to the output directory supplied to SuiteRunner. When Maven Surefire runs the suite, its TestNG integration adds HTML and XML listeners; inspect Maven’s configured report output rather than assuming the standalone TestNG directory.
This guide shows a working Java setup, explains where reports go, and helps you choose built-in HTML, XML, ITestListener, or IReporter output.
What TestNG generates for a Selenium run
TestNG owns the reporting; Selenium only drives the browser. A basic TestNG execution creates index.html in the directory specified when SuiteRunner starts. The page links to additional HTML and text files containing the run results. Open the file in a browser after the run completes.
That location is not necessarily the same as Maven’s location. The launcher, Surefire version, suite XML, and plugin configuration can all change where files are written. Treat the output directory as a runtime setting, not a universal path.
#1 Best Overall
Check Java and TestNG compatibility first
Use a TestNG release compatible with the JDK used by your build. The TestNG project states that releases through 7.5 require JDK 8, while TestNG 7.6.0 and later require JDK 11 or newer. Its current documentation identifies TestNG 7.9.0 and shows a JDK 11 Maven example. Do not copy a dependency version blindly: align it with your project’s JDK and other plugin constraints.
- JDK 8 project: choose a TestNG version no later than the 7.5 line.
- JDK 11 or newer: TestNG 7.6.0+ is supported; 7.9.0 is the documented example.
- Confirm the same Java version is used by your IDE, Maven, and CI runner.
Minimal Selenium and TestNG project
Add TestNG as a test dependency and keep Selenium tests under Maven’s test source tree. This example uses TestNG 7.9.0 for a JDK 11+ project; change the version when your JDK requires it.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
</dependency>
A small test can use Selenium WebDriver in the usual way:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class LoginTest {
private WebDriver driver;
@BeforeMethod
public void setUp() {
driver = new ChromeDriver();
}
@Test
public void pageHasExpectedTitle() {
driver.get("https://example.test/");
Assert.assertTrue(driver.getTitle().contains("Example"));
}
@AfterMethod
public void tearDown() {
if (driver != null) driver.quit();
}
}
Replace the URL and assertion with your application’s test. The report records TestNG events and results; it does not automatically embed browser screenshots.
Generate the built-in report with a TestNG suite
- Create a suite file, for example
testng.xml:
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Selenium suite">
<test name="UI tests">
<classes>
<class name="LoginTest"/>
</classes>
</test>
</suite>
- Launch that suite with your existing TestNG runner, selecting an output directory when the runner supports it. A direct
SuiteRunnerexecution writesindex.htmlthere. - Open
index.htmlafter execution. Follow its links to passed, failed, skipped, group, and text result pages.
If your IDE runs TestNG internally, use the IDE’s run configuration or console output to identify the report directory. The exact path is launcher-specific.
Rank #2
Generate reports through Maven Surefire
Surefire’s TestNG integration attaches basic listeners that produce HTML and XML reports by default. Run:
mvn test
After the build, inspect Maven’s report directories and the path printed by your build. Do not assume the standalone SuiteRunner index.html location: Surefire versions and configuration determine the actual files.
A suite can be selected explicitly in the Surefire configuration. Keep the plugin version and any report-directory settings in the same pom.xml used by CI so local and pipeline output remains predictable. If no files appear, first verify that tests were discovered and that the build did not stop before the reporting phase.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChoose the right TestNG reporting API
ITestListener: events while tests run
Implement org.testng.ITestListener when you need immediate notifications as tests start, pass, fail, skip, or finish. Typical uses include logging a failure, capturing a Selenium screenshot at the moment of failure, or sending a live status event. Register the listener in testng.xml or with the @Listeners annotation.
import org.testng.ITestListener;
import org.testng.ITestResult;
public class RunListener implements ITestListener {
@Override public void onTestFailure(ITestResult result) {
System.err.println("Failed: " + result.getName());
}
}
import org.testng.annotations.Listeners;
@Listeners(RunListener.class)
public class LoginTest { /* tests */ }
IReporter: assemble a report after all suites
Implement org.testng.IReporter when the complete result is needed after execution. TestNG calls generateReport after all suites finish and supplies suite-result objects plus an output directory. This is the appropriate extension point for a consolidated HTML, PDF, dashboard, or other post-run artifact.
Rank #3
import java.util.List;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.xml.XmlSuite;
public class SummaryReporter implements IReporter {
@Override
public void generateReport(List<XmlSuite> xmlSuites,
List<ISuite> suites,
String outputDirectory) {
System.out.println("Report directory: " + outputDirectory);
// Write your consolidated report here.
}
}
For Maven, configure custom listeners or reporters through Surefire’s supported TestNG configuration. Keep listener registration in one place to avoid duplicate events when both annotations and build settings register the same class.
Use XML when another tool consumes the results
TestNG’s XMLReporter writes XML containing TestNG-specific information that may not exist in a JUnit-format result. It supports documented properties for output directory, file fragmentation, stack-trace detail, group attributes, result attributes, timestamp formatting, and dependency information.
For a direct command-line run, the documented reporter form is:
-reporter org.testng.reporters.XMLReporter
Reporter properties are supplied using the colon-separated syntax supported by the runner. In Maven, use the corresponding Surefire configuration instead of mixing command-line-only settings into the POM. XML is generally the better interchange format for CI parsers, history databases, and custom dashboards; built-in HTML is easier for a person to browse.
Add useful Selenium context safely
Reporter.log("message") adds a message to generated TestNG HTML reports. Log short, actionable context around browser actions, such as the page under test, a business step, or an identifier for a saved artifact.
Rank #4
- Prefer “Checkout: submitting order” to a large HTML dump.
- Never log passwords, access tokens, cookies, authorization headers, or sensitive page data.
- When capturing screenshots on failure, use a unique filename containing the test name and timestamp, then link or attach it from your custom report.
Troubleshooting missing or incomplete reports
No index.html appears
Confirm that you performed a direct TestNG/SuiteRunner launch and supplied an output directory. If Maven ran the tests, inspect Surefire’s configured output instead; it may not use the standalone directory.
Recommended Free Tools
The report is empty
Check test discovery: class names, @Test annotations, suite XML package/class entries, and Maven’s test-source layout. A build that discovers zero tests can still finish without a useful result page.
Only some tests are listed
Look for suite filters, groups, included/excluded methods, parallel settings, and an early JVM failure. Read the console log before diagnosing the HTML.
XML exists but a dashboard rejects it
Verify that the consumer expects TestNG XML rather than JUnit XML. TestNG’s XML reporter intentionally includes TestNG-specific structures; map those fields or select the consumer’s supported format.
Listener runs twice
Search both @Listeners annotations and testng.xml/Surefire configuration. Remove the duplicate registration and run a clean build.
Best Value
Wrong JDK or dependency errors
Print the Java version used by Maven and compare it with the TestNG release line. Upgrade the JDK for TestNG 7.6.0+ or select a compatible older TestNG release for JDK 8.
Selenium failure hides the useful cause
Keep the original exception, log the URL and test step, and capture the browser artifact in onTestFailure. Avoid replacing the assertion failure with an unrelated screenshot I/O exception.
Performance, reliability, and storage decisions
- Write reports to a clean directory per run, especially in CI, so stale HTML is not mistaken for current results.
- Retain XML for machine processing and archive HTML only as long as your investigation policy requires.
- Parallel tests need unique artifact names and thread-safe listener state.
- Large logs and screenshots slow artifact upload. Keep full-resolution evidence for failures and concise messages for passing steps.
- Always publish the report directory as a CI artifact when the build agent is ephemeral.
Or skip the browser setup
If your workflow needs screenshots of test pages or reports rather than a browser driver, ScreenshotNeo provides a single HTTP request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.
See the complete parameter list in the ScreenshotNeo documentation. cURL:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every plan includes its features; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Frequently Asked Questions
Does TestNG automatically take Selenium screenshots?
No. TestNG reports test results and log messages; add a listener or reporter that calls Selenium’s screenshot API when you need image evidence.
Can I use both HTML and XML reports?
Yes. Surefire’s TestNG integration provides basic HTML and XML listeners, and you can add custom listeners or reporters for additional output.
Which API should create a final PDF-style summary?
Use IReporter, because TestNG invokes it after all suites complete and provides the aggregated suite results and output directory.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

