I’ve been receiving some queries related to how we customize the extent report that has been generated. Queries like:
Let’s see one by one. Before diving in, let’s create a xml file called extent-config.xml (you can name it whatever you want) in the src/test/resources/ directory. The following suggestions should be done on this file only.
Open extent-config.xml file and add the following code:
<?xml version="1.0" encoding="UTF-8" ?>
<extentreports>
<configuration>
<encoding>UTF-8</encoding>
<documentTitle>My Custom Browser Title</documentTitle> <!-- This title will be displayed as browser title for the page -->
<reportName>My Custom Report Title</reportName> <!-- This will be your report heading -->
<reportHeadline>A small headline</reportHeadline>
</configuration>
</extentreports>
Add the following in your xml file under the configuration node:
<theme>dark</theme>
Add the following in your xml file under the configuration node to default the Parent Tests only mode:
<scripts>
<![CDATA[
$(document).ready(function() {
$('#parentWithoutNodes').prop("checked", true).click();
$('#test-count-setting > div.modal-footer > a')[0].click();
});
]]>
</scripts>
To default to Child Tests only mode, replace #parentWithoutNodes to #childNodes.
Add the following in your xml file under the configuration node:
<protocol>http</protocol>
This will make sure that all the stylesheets and scripts will follow the http protocol.
Now once you have created your custom config xml file, you will have to load that.
If you are using CucumberExtentReporter, add the following line of code in your runner.
ExtentCucumberFormatter.loadConfig(new File("src/test/resources/extent-config.xml"));
Now re-run and open the generated report to see the customized extent report.
Update: Updated the xml config to select the Parent Tests only and click on Save button. Thanks to Alexei who pointed out.