How to Add Extent Report in the Selenium-Cucumber Framework

In the Test automation framework, it is important to generate visually appealing HTML reports for effective communication of test execution results. In this post, we will learn how to integrate Extent Report in the Selenium Cucumber Framework.

What is ExtentReport?

Extent Report is a powerful, open-source library used in testing automation frameworks for generating beautiful and user-friendly HTML reports. It allows the user to customize the report template by using custom CSS, JSON, or XML.
You can read more about it at


Before generating the Extent reports few requisites need to be followed.

  1. Java Development Kit (JDK) installed on your system.
  2. Maven installation for managing dependencies.
  3. Selenium WebDriver for browser automation.
  4. Add Cucumber Java dependence.
  5. Add TestNG Dependence.

Integration of Extent Report in Test Automation Framework

Follow step by step to integrate Extent Report successfully in the Selenium test automation framework.

a) Add extent reports-cucumber7-adapter dependency in the pom.xml file.

Open IDE and open the Selenium-TestNg-BDD project. Add the below dependency in the pom.xml file.


b) Create a file named “extent. properties” in the src/test/resources folder.

Navigate to the src/test/resources folder and add a new properties file. Name it ‘’ and add the below code.


#PDF Report

#HTML Report

basefolder.datetimepattern=d-MMM-YY HH-mm-ss


systeminfo.user={User name}{Build version}
systeminfo.AppName={App name}

c) Add the Plugin in class

Go to the project and open the Cucumber Runner file. Add the avent stack extent report plugin inside the plugin section of the CucumberOptions annotation.

		features = { "src/test/resources/features" }, 
		glue = { "path of your step definition" }, 
		plugin = { "pretty",
		"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" } 

After completing all the setup and configuration execute your TestRunner class and refresh the project. A base folder will be created named reports. Open this folder, under this folder we will see the HTML report, PDF report and spark report.


Right-click on the HTML Report and open it in the browser. This report contains information related to the test execution summary like total test cases executed, total test cases passed, failed test cases, Start date, duration etc. Open and analyse PDF reports and spark reports.

We can configure the extent report using an XML file or JSON file as well.

Extent Report configuration using XML:

To configure the extent report using XML we need to create an extent-config.xml file in the src/test/resources folder. Add the below configuration in the XML file. In the XML config file, we can set the elements :

  1. Theme: Dark or Standard.
  2. Document encoding: UTF-8
  3. Document Title: Will display on the browser Tab.
  4. Report Name: Will display on the top of the report.
<?xml version="1.0" encoding="UTF-8"?>
		<!-- report theme -->

		<!-- standard, dark -->

		<!-- document encoding -->

		<!-- defaults to UTF-8 -->

		<!-- protocol for script and stylesheets -->

		<!-- defaults to https -->

		<!-- title of the document -->
		<!-- report name - displayed at top-nav -->

		<reportName>App Web Report</reportName>
		<!-- location of charts in the test view -->

		<!-- top, bottom -->

		<!-- custom javascript -->


$(document).ready(function() {
		<!-- custom styles -->

Other steps will remain the same. Read this XML file in your test script. Now, execute your test script and refresh the project. The report will be generated inside the target/HTML folder.

Customize Report Folder: When we execute the test script then the previous report will be overridden and a new report will generate. To overcome this we need to maintain the backup of all the test execution results. To do this we can add two properties to the properties file.
basefolder.datetimepattern=d-MMM-YY HH-mm-ss

If there is a requirement to attach the screenshot to the extent report that can also be achieved by adding a few more properties to the .properties file.


There are a few more properties that can be used to customize the extent reports as per the requirement. By Doing so users can get a more extensive and insightful perspective on the test results.


In this post, we have learned in detail how we can add an extent report in the Selenium framework. You can explore the below course for the Selenium automation framework.

  1. Selenium Java Test automation framework.

Leave a Reply

Discover more from AutomationQaHub

Subscribe now to keep reading and get access to the full archive.

Continue reading