Generate Extent Report in Selenium: Extent 3

In Automation Software Testing execution report is the evidence to verify the pass and fail status of Tests. Most of the licensed automation testing tools will have in built rich report option to show the execution status. But coming to open source automation tools lacking in this option.

In the same way Selenium doesn’t have reporting feature, To generate the report in selenium user need to use Testing Framework like TestNG or JUnit. We have seen, How can you use TestNG with selenium and How can you use JUnit with Selenium. We have also seen the TestNG Reporting and ReportNG HTML reporting with TestNG. In this tutorial, You will see, How can you generate the Extent Report in Selenium WebDriver.


Generate Extent Report in Selenium

Extent reports are very rich HTML reports for the selenium webdriver. This report will give so much of information about the execution status. The extra information can be provided from the external XML file. Once you create the XML file need to load in the program to read the configuration.


Extent Report in Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.


Let’s see, How can you generate the Extent Report in Selenium –

Pre-requisites to Generate Extent Reports:

  1. Java should be installed (Link to Install and setup Java )
  2. TestNG should be installed
  3. Extent Report Jars
  4. extent-config.xml – It allows to configure HTML Report


Steps To Generate Extent Reports:

  1. Firstly, create a TestNG project in eclipse
  2. Now download extent library files from the following link: Download Extent Report
  3. Add the downloaded library files in your project


To understand it better, Let’s design our Test Class first.  We have created the Test Class named “SampleExtentReport” and added the Extent Jar files as external jars in my Test Project.

Code Explanation:

i. Imported two classes ExtentReports and ExtentTest.

ExtentReports & ExtentHtmlReporter By using this class we set the path where our reports need to generate.

ExtentTestBy using this class we could generate the logs in the report.

ii. Took three methods with @Test annotation such as demoTestPasd, demoTestFail and demoTestSkip and a method startTest with @BeforeTest annotation and another method endReport with @AfterMethod annotation.

iii. Used object of ExtentReports and ExtentHtmlReporter class  in the startReport method which was assigned to @BeforeTest annotation to generate the HTML report in the required path. And added the system information in the same method.

iv. Used object of ExtentTest class (i.e., logger) in the remaining methods to write logs in the report.

v. Used ITestResult class in the @AfterMethod to describes the result of a test.

You can go through the code for better explanation and understanding.


You should note, We are not using external XML file (extent-config.xml) in our code. It is not necessary to implement this file while using the extent report.


Console Output:

Execute the Test Class and Refresh the project after execution of above file. You could find an HTML file named “myExtentReport.html” in your test-output folder. Copy the location of the myExtentReport.html file and open it by using any browser. You could see a beautiful high rich HTML reports as shown below.

Test Summary Report:


This way we could generate extent reports. In our next tutorial, We will see the advance feature of Extent Report.

  1. vikas tripathi 2:27 AM / July 27, 2017 - Reply

    nice article. keep it up good work

  2. Malkit Sidhu 7:15 PM / October 22, 2017 - Reply

    Good. very informative article Anshul. I tried to follow your example exactly and “test-output” dir is created but the file is not. Any thoughts?

    • Malkit Sidhu 7:48 PM / October 22, 2017 - Reply

      I am applying to my own question. I have Extent Reports ver.3.0.7 and apparently, It does not create the file if it doesnt exist. So manually creating the file, fixes the problem.

      • Anshul Chauhan 8:54 PM / October 27, 2017

        It’s always nice to learn form our own mistakes 🙂

  3. sam 1:27 AM / October 26, 2017 - Reply

    could you please tell me how to implement extent reports

    1. when tests are in different classes.
    2. when one test has to run for multiple test data.

    • Anshul Chauhan 8:52 PM / October 27, 2017 - Reply

      Hey Sam, It’s easy. You just need to change your Test Code Structure. Do one thing implement some common Utility which will implement the extent report and use that in your test case. So that Extent will be test class independent and it’s nothing to do with your test data, as it refers Test Cases.

Leave a Reply