Extent reports help you see test results clearly. Customizing them makes reports easier to read and understand.
Extent report customization in 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.
htmlReporter.config().setDocumentTitle("Login Tests Report"); htmlReporter.config().setReportName("Login Module"); htmlReporter.config().setTheme(Theme.DARK);
extent.setSystemInfo("Tester", "Alice"); extent.setSystemInfo("Environment", "QA");
ExtentTest test = extent.createTest("Test Case 1").assignCategory("Smoke");
This program creates a customized Extent report with title, name, theme, system info, and two tests with pass/fail status.
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(); } }
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.
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.
Practice
Solution
Step 1: Understand Extent report role
Extent reports show test results in a readable format.Step 2: Identify customization benefits
Customization helps make these results clearer and more useful.Final Answer:
To make test results clearer and easier to understand -> Option AQuick Check:
Customization = clearer test results [OK]
- Confusing report customization with test speed
- Thinking customization changes test logic
- Assuming customization fixes test errors
Solution
Step 1: Recall ExtentReports theme setting syntax
Use config() method and setTheme with Theme enum.Step 2: Match correct method and enum usage
Only extentHtmlReporter.config().setTheme(Theme.DARK); uses config().setTheme(Theme.DARK) correctly.Final Answer:
extentHtmlReporter.config().setTheme(Theme.DARK); -> Option AQuick Check:
Use config().setTheme(Theme.DARK) [OK]
- Using setTheme directly without config()
- Passing theme as string instead of Theme enum
- Using incorrect method names
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("testReport.html");
htmlReporter.config().setDocumentTitle("My Test Report");
ExtentReports extent = new ExtentReports();
extent.attachReporter(htmlReporter);
Solution
Step 1: Identify method setting report title
config().setDocumentTitle("My Test Report") sets the HTML page title.Step 2: Understand effect on report
The report's browser tab will show "My Test Report" as title.Final Answer:
My Test Report -> Option CQuick Check:
setDocumentTitle sets report title [OK]
- Confusing file name with report title
- Assuming default title is used
- Ignoring config() method effects
ExtentHtmlReporter reporter = new ExtentHtmlReporter("report.html");
ExtentReports extent = new ExtentReports();
extent.attachReporter(reporter);
// Missing flush call
Solution
Step 1: Check report saving process
Extent report requires extent.flush() to write data to file.Step 2: Identify missing flush call
The code does not call extent.flush(), so report is not saved.Final Answer:
Missing call to extent.flush() to save the report -> Option DQuick Check:
Always call extent.flush() to save report [OK]
- Forgetting to call flush()
- Changing file extension incorrectly
- Misunderstanding attachReporter usage
ExtentReports extent = new ExtentReports();
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("sysInfoReport.html");
extent.attachReporter(htmlReporter);
// Add system info here
extent.flush();Solution
Step 1: Identify correct method to add system info
ExtentReports class has addSystemInfo method to add info.Step 2: Confirm usage on ExtentReports instance
System info is added on extent, not on htmlReporter.Final Answer:
extent.addSystemInfo("OS", System.getProperty("os.name")); extent.addSystemInfo("Java Version", System.getProperty("java.version")); -> Option BQuick Check:
Use extent.addSystemInfo() before flush [OK]
- Calling setSystemInfo on htmlReporter instead of extent
- Using setSystemInfo which does not exist
- Adding system info after flush()
Ready to prove it?
Pass the test and this pattern moves unknown
