Extent reports help you see test results clearly. Customizing them makes reports easier to read and understand.
0
0
Extent report customization in Selenium Java
Introduction
You want to add your company logo to test reports.
You need to change report colors to match your project theme.
You want to add extra information like tester name or environment.
You want to organize test results by categories or tags.
You want to save reports with custom file names or locations.
Syntax
Selenium Java
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("path/to/report.html"); ExtentReports extent = new ExtentReports(); extent.attachReporter(htmlReporter); // Customize report htmlReporter.config().setDocumentTitle("My Test Report"); htmlReporter.config().setReportName("Regression Tests"); htmlReporter.config().setTheme(Theme.STANDARD);
Use ExtentHtmlReporter to create and customize the HTML report.
Call attachReporter to link the reporter to your ExtentReports object.
Examples
This sets a custom title, report name, and uses a dark theme for better visibility in low light.
Selenium Java
htmlReporter.config().setDocumentTitle("Login Tests Report"); htmlReporter.config().setReportName("Login Module"); htmlReporter.config().setTheme(Theme.DARK);
Adds extra info about who tested and which environment was used.
Selenium Java
extent.setSystemInfo("Tester", "Alice"); extent.setSystemInfo("Environment", "QA");
Assigns a category to a test to group similar tests in the report.
Selenium Java
ExtentTest test = extent.createTest("Test Case 1").assignCategory("Smoke");
Sample Program
This program creates a customized Extent report with title, name, theme, system info, and two tests with pass/fail status.
Selenium Java
import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.reporter.ExtentHtmlReporter; import com.aventstack.extentreports.reporter.configuration.Theme; public class ExtentReportDemo { public static void main(String[] args) { ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("test-output/MyReport.html"); htmlReporter.config().setDocumentTitle("My Test Report"); htmlReporter.config().setReportName("Sample Tests"); htmlReporter.config().setTheme(Theme.STANDARD); ExtentReports extent = new ExtentReports(); extent.attachReporter(htmlReporter); extent.setSystemInfo("Tester", "Bob"); extent.setSystemInfo("OS", "Windows 11"); ExtentTest test1 = extent.createTest("Test Login").assignCategory("Functional"); test1.pass("Login test passed successfully."); ExtentTest test2 = extent.createTest("Test Logout").assignCategory("Functional"); test2.fail("Logout test failed due to timeout."); extent.flush(); } }
OutputSuccess
Important Notes
Always call extent.flush() at the end to save the report.
Use meaningful categories to filter tests easily in the report.
Customize colors and logos to make reports look professional and match your brand.
Summary
Extent report customization makes test results clearer and more useful.
You can change titles, themes, add system info, and organize tests by categories.
Remember to attach the reporter and flush the report to save changes.