3 Unique Ways to Generate Reports in Selenium Webdriver

A perfect test automation tool is what you need for the successful execution of the testing requirements in the Agile process. And there are multiple factors which play a critical role in the formation of a robust automation framework. One such factor is reporting which not only make you aware of the status of the success or failure but helps you in finding out the potential bugs. So, you should mindfully choose how you are going to generate reports in Selenium Webdriver project. That’s where this post would lead you to make a decision. You’ll see three cutting edge techniques that can help you generate reports which are user-friendly, intuitive and informative.

Before we proceed with the topic, it is essential that you clearly understand what is the purpose of reporting? You need it because the test report serves as a health card of the ongoing project which you can share with the stakeholders. It gives them a definite idea of the actual state of the product so that they can decide to ship it to the customer or allow the team to focus on the shortcomings cited in the report.

What are the essential qualities of a good test report?

  • Brevity –
    • A report should be short and concise.
    • It should clearly state the proportion of total no. of success or failure.
  • Trackability –
    • Captures all the footprints that could lead to the root cause of a failure.
  • Traceability –
    • It must provide the ability to review the following.
      • Historical data for test cases and failures.
      • Age of a particular failure.
  • Sharable –
    • It should support a format which you can share through email or integrate with CI tools like Jenkins/Bamboo.
  • Test coverage –
    • It should highlight the test coverage for the following.
      • Test coverage of the module under test.
      • Test coverage of the application under test.

Now you would have gained a fair idea of the fact that how a good test report can maximize the returns on investment. Let’s move our focus to three techniques that you may use to generate reports in Selenium Webdriver. Here are the quick links that can navigate you to the report generation methods of your choice.

3 Techniques to Generate Reports in Selenium Webdriver.

3 Unique Ways to Generate Reports in Selenium Webdriver

3 Unique Ways to Generate Reports.

Selenium Webdriver doesn’t have a built-in reporting feature but there are plugins like the TestNG and JUnit which can add this functionality.

1- Generate Reports Using TestNG.

TestNG library brings a very convenient reporting feature. Once you execute the tests, TestNG generates a test output folder at the root of the project. It combines two kinds of reports.

Detailed report.

You can find this report in the <index.html> file. It combines the detailed information like the errors, test groups, execution time, step-by-step logs and TestNG XML file.

Generate Reports (index.html) in TestNG

Generate Reports (index.html) in TestNG.

 Summary report.

It is the trimmed version and informs about the test pass/fail/skip count. You can see it from the <emailable-report.html> file. It’s an email friendly report which you can embed and share with the stakeholders.

Generate Reports (emailable-report.html) in TestNG

Generate Reports (emailable-report.html) in TestNG.

Back to top

1.1- Steps to Generate Reports Using TestNG.

Step-1) Select the TestNG Reporting Interface.

TestNG supplies two interfaces to implement reporting in Selenium Webdriver. You can apply any of these two in your projects.

  1. Testers commonly use the <ITestListener> Interface.
  2. Another is the <IReporter> Interface which is least popular.

In this blog post, we’ll cover the application of the <ITestListener> Interface. You’ll have to create a TestNG project in Eclipse. You can refer our below post that teaches to create a basic TestNG project.

Step-2) Generate Reports Using the <ITestListener> Interface.

Back to top

Step-3) Verify the Report Generation Process.

Back to top

2- Generate Reports Using JUnit.

JUnit is another very good tool that can add intuitive reporting feature in your Selenium project. It provides the JUnit <TestWatcher> class to introduce reporting ability.

The JUnit’s TestWatcher class has the <failed()> and <succeeded()> methods which you can override. The JVM would call them automatically whenever it smells a pass or failure.

2.1- Steps to Generate Reports in JUnit style.

We’ve just summarized the summary of the steps that you can use to generate reports using the JUnit plugin.

  1. Create a new Java class (name it as JUnitTestReporter) that applies the JUnit rules with the help of the TestWatcher() class.
  2. Override the <succeeded()> method so that the names of passed tests could get displayed at the console with the <Passed> status.
  3. Override the <failed()> method so that the names of the failed tests could appear at the console with the <Failed> status.
  4. Create a sample test class as <JUnitSampleTest> which must extend the <JUnitTestReporter> class to utilize the overridden <succeeded()> and <failed()> methods.

Now we’ll explain how simple it is to work with JUnit so that you can quickly generate the summary of the test execution.

2.2- Simple Report Generation Using JUnit.

2.2.1- Generate Reports by creating a JUnit Test Watcher Class.

Create a simple project in Eclipse and add the below file <JUnitTestReporter.Java> to your project. This file will display the report into the Eclipse console.

Back to top

2.2.1- Prepare a Sample JUnit Test Suite to Verify Report Generation.

Also, add the below file <JUnitSampleTest.Java> to your project. It’ll be the main test file which you’ll execute from the Eclipse.

When you run the above JUnit tests from Eclipse, it’ll show you the test results in Eclipse as captured in the below screenshot. The downside to this technique is that it doesn’t save the output in an HTML file.

Generate Reports Using JUnit Plugin

Generate Reports Using JUnit Plugin.

But you can generate an HTML report by modifying the above code. We’ve given the technique to produce the test summary in the next section. It saves the report in an HTML file.

Back to top

2.3- HTML Report Generation Using JUnit.

We’ll create a new JUnit class that would enable the HTML report generation. This class will also override the TestWatcher methods to implement the desired features.

  • We’ll define two static members; one is a File object and the second one is BufferWriter’s handle that will help us adding the test execution summary to the report file.
  • We’ll use the following JUnit annotations.
    • @BeforeClass – It’ll help us define the setup() method. It’ll create/open the HTML report file as per the situation.
    • @AfterClass – We’ll use it for the purpose of cleanup. It’ll also update the HTML report file to add the HTML footer and close all the open handles.
  • We’ll override the following two methods.
    • <succeeded()> method – It’ll write the names and status of the test cases passed during execution.
    • <failed()> method – It’ll log the names and status of the test cases failed during execution.

Now, you’ll find the source code of the <JUnitHTMLReporter> class.

Back to top

So, we have a ready to use HTML reporter class, all we need now is the JUnit Test class that will extend it and call its methods. The code of this new class is available below.


When you run the above class file as JUnit test case, then the <junitReportFile.html> will get generated. It’ll contain the test cases pass/fail info and look like the one as given in the below screenshot.

Generate Reports in HTML Format Using JUnit

Generate Reports in HTML Format Using JUnit.

Back to top

3- Generate Reports Using Extent Library.

The third and the last technique for generating some awesome reports is by using the <Extent Report> library. It comes with a rich set of features.

  • Ability to generate dynamic HTML logs.
  • Represents test case status with the help of PIE Charts.
  • Generates step-by-step test case summary.
  • Ability to filter reports based on test status.
  • It maintains execution history.
  • It captures details like OS, Memory, Java version and so on.
  • You can attach error screenshots within the report.

You can download the Extent library from the below URL.

Generate Reports Using Extent Library

Download Extent Library Jar Files.


Once you have the reporting library, then follow the below steps to use them in a Selenium Webdriver project.

  • Create or open a demo project in Eclipse.
  • Add the Jar files shown in the above picture as external libraries to your project.
  • Also, make sure to add the Jars that are under the <lib> folder else the exception may occur at run-time.

Now, we are attaching the source code of the sample Java program that we’d created for the Extent report validation. You can use the below Java file as is in your demo project.

Back to top

Once you run the above code, it’ll launch the specified URL in Firefox and produce an intuitive Extent test report. The final test report would look like the one shown in the below screenshot.

Generate Reports in Selenium Webdriver

Live Extent Report Example.


So, that was all we wanted to share in this post. We hope it would enable you to use the three distinct methods to generate reports in Selenium. And, you’ll be able to reap the real benefits of the test automation.

Back to top

Quick Review – Report Generation Techniques in Selenium.

In this post, we discussed all the traditional and modern day report generation techniques. We wish that they would be quite useful in your projects. Now, it’s completely up to you how you manage them. If you face any problem in using them then just drop us an email or leave your queries in the comment box available at the end of the post. We’ll try to respond to your questions at the earliest.

However, if you come across some other way of adding the reporting feature to a Selenium project then do share it with us. We’ll review and publish it on our blog with a ‘Thank You‘ note mentioning your name.


All the Best,



  1. Jigs Reply
    • Meenakshi Agarwal Reply
  2. Sebastian Reply
    • Meenakshi Agarwal Reply
  3. Yogiraj Reply
    • Meenakshi Agarwal Reply
      • Yogiraj Reply
        • Meenakshi Agarwal Reply
        • vijay Reply
    • Meenakshi Agarwal Reply

Leave a Reply