How to Generate Extent Reports in Selenium

How to Generate Extent Reports in Selenium

Extent Reports is a robust, open-source library for generating detailed test automation reports. It seamlessly integrates with testing frameworks like JUnit and TestNG to provide HTML-encoded and PDF-formatted reports. These reports are crucial for Quality Assurance (QA) teams as they summarize test results and pinpoint specific areas of failure in test scripts, making them more informative than many standard reporting tools provided by testing frameworks.

What are Extent Reports?

Extent Reports enhance the reporting capabilities of test automation frameworks by providing HTML-encoded PDFs that display results in visually informative pie charts. Unlike the basic HTML reports generated by frameworks such as TestNG, Extent Reports offer a high level of detail and clarity, showcasing exactly where scripts fail and thus facilitating a more effective debugging process.

How to Use Extent Reports in Selenium

  • Initialization of Reports

    ExtentReports reports = new ExtentReports("Path of directory to store the HTML file", true);

    • Purpose: Initializes a report that will either overwrite an existing report or create a new one based on the Boolean flag (true for overwrite).
    • Parameters

      Path of directory: Specifies where the HTML report file will be saved.

      true/false: A Boolean flag indicates whether to overwrite the existing report.

  • Creating a Test Report

    ExtentTest test = reports.startTest("TestReportName");

    • Purpose: Starts a new test within the report.

    • Parameters

      TestReportName: The name of the test for identification in the report.

  • Logging Test Steps

    Method: Use the test.log() method to document each test case step, indicating status and details.

    • Example Usage:

      test.log(LogStatus.PASS, "Step description here");

  • Completing the Test

    Method: Utilize reports.endTest(test) to finalize the logging for a specific test

  • Generating the Report

    Method: Call reports.flush() to finalize and save the report, ensuring all data is written to the file.

Below is the Syntax for Extent Reports

ExtentReports reports = new ExtentReports("Path of directory to store the HTML file", true/false);

ExtentTest test = reports.startTest("TestReportName");

Extent report classes can be used with the following built-in methods:

  • startTest: Executes the set preconditions of a test case
  • endTest: Executes the set postconditions of a test case
  • Log: Logs the status of every test step into the HTML report getting generated
  • Flush: Removes any previous data from any report and creates a new report

The status of the test can be indicated by the following values:

  • Pass
  • Fail
  • Skip
  • Info

Pros & Cons of Using Extent Reports


  • Detailed Summaries: Offers comprehensive summaries of testing sessions, including counts of tests run, passed, and failed.
  • User-friendly Formats: Generates reports in PDF format, which are easy to read and do not require command line interactions.


  • Fixed Categorization: Tests must be categorized into predefined suites, which might limit flexibility in reporting.
  • Time Recording: Documents the total duration of test runs, which can be cumbersome to analyze for long test suites.
  • Limited Tool Integration: Does not integrate with some tools like JIRA, making it less suitable than other reporting tools like Allure Reports for projects that use these integrations.


Extent Reports provide a valuable tool for enhancing the effectiveness of test reporting in Selenium by offering detailed, easily navigable reports that help pinpoint failures. While they offer significant advantages in terms of detail and ease of use, their lack of integration with tools like JIRA and rigid categorization can be seen as drawbacks. Nevertheless, for teams prioritizing detailed insights and visual reporting, Extent Reports are an excellent choice.


This publication is for informational purposes only, and nothing contained in it should be considered legal advice. We expressly disclaim any warranty or responsibility for damages arising out of this information and encourage you to consult with legal counsel regarding your specific needs. We do not undertake any duty to update previously posted materials.

Post a Comment