Selenium HTML result reporting using ExtentReports 3.X

selenium-result-reporting-using-extent-reportIn our earlier post (Selenium reporting using extent 2.x), we have seen as a starting point how to generate report at end of test execution using 2.x version.

As extent report is becoming more popular and they are also trying to make it more flexible by providing frequent updates, so in this post, we will be discussing more in detail about the newly release version 3.0 (till now), which is of quite different in configuration (of course, concept remains same :D).

Find the required dependencies from following links

Let’s look into the code implementation

1st thing, we need a utility or base class ( that takes care all the extent configuration, so that test cases will be using this to generate report.

Create testcases, log results or steps to generate report

run the, refresh your project, you will see extentreport.html created, open html page in a browser to see the extent report.

Explanation :

in, we are getting the objects of ExtentReports, ExtentHtmlReporter and ExtentTest , so separate test cases can use those objects to send test results to generate report.

each test case will have

  • @BeforeClass – get the ExtentReports object and some test case specific code statements.
  • @Test  – actual test case functionality.
  • @AfterClass – to write the test case results in to html (extent.flush())

All other code statements are explained with below screenshot


Configuration :

Extent report can be customized or configured by using ExtentHtmlReporter.config() (e.g – setDocumentTitle, setReportName) or by using config.xml and load it at run time.

NOTE: In the above code implementation, we saw how to configure extent report using ExtentHtmlReporter.config()

Now let’s see how we can load and cofigure report using config.xml

a typical config.xml –

Do required changes to the config.xml and place under your project folder, and change the a bit to use the xml file.


References –

github – extent report in java

Update –

Updated GetExtent() under class ExtentManager

if(extent != null)

return extent; \\to avoid creating new instance of html file at every test run

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

14 Responses

  1. Rahul Rana says:

    I have multiple class files with multiple methods in it. I need one report for the entire run but the all reports are overwritten and report for only last class is visible. I tried changing extent = new ExtentReports(); to extent = new ExtentReports(path, false); but its not allowing me to do it

  2. sunilpatro1985 says:

    Workaround to your problem –
    Download extentreports-3.0.1.jar and replace existing jars with this latest to the current project, and add htmlReporter.setAppendExisting(true); under the GetExtent() method.

    NOTE: make sure every time you execute tests, create an empty html file or else it will append even all your prev results.

  3. srikanth says:

    I took your source code to generate report. I just created the same

    I have my own test . when i execute I am not getting any error but the output is not generated.

    I am using extentreports 3.0.2. I am new to testng and extent reports.

    Could you please help me

  4. dsa127 says:

    Do you not have to use endTest(testName) anymore?

    • sunilpatro1985 says:

      Not required, extent.flush() will do that for you, are you getting any issues generating report with out endtest(testname)?

  5. mahi says:

    can we execute Jmeter script through this extent class and generate extent reports

  6. Diana says:

    Thank you sunilpatro1985 · , this was really helpful!
    But I have a problem with encoding. All my descriptions in cyrillic, last running test case is shown in report with cyrillic. But the other test which was run before shown like symbols (question marks).
    I change config xml cp1251 but it doesn’t help

  7. Gangotri Sikheria says:

    Hello AnsooArora,
    I want to generate extent report according to date wise, right now it is overtire result in same file, Please help me

    Gangotri SIkheria

    • sunilpatro1985 says:

      Create a variable in which will hold the date and time and append this variable to html file path, so the html file will not overwrite every time you run test and generate report…
      Hope that helps!

  8. Maribel says:

    There is certainly a great deal to learn about this topic.
    I really like all the points you have made.

  9. vik says:

    I get the error as FAILED CONFIGURATION: @AfterTest tearDown
    java.lang.NoClassDefFoundError: org/bson/types/ObjectId

    code is below
    package AutFramework;

    import static org.testng.Assert.assertTrue;

    import org.openqa.selenium.WebDriver;
    import org.testng.ITestResult;
    import org.testng.annotations.AfterMethod;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;

    import com.aventstack.extentreports.ExtentReports;
    import com.aventstack.extentreports.ExtentTest;
    import com.aventstack.extentreports.Status;
    import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
    import com.aventstack.extentreports.reporter.configuration.ChartLocation;
    import com.aventstack.extentreports.reporter.configuration.Theme;

    public class AdvanceReporting {

    WebDriver driver;
    ExtentHtmlReporter htmlReports;
    ExtentReports extent;
    ExtentTest test;
    String fileName = System.getProperty(“user.dir”)+”/test_output/HtmlTestResults.html”;

    public void setUp() {
    htmlReports = new ExtentHtmlReporter(fileName);
    extent = new ExtentReports();

    public void openBrowser()
    test = extent.createTest(“TC_1 = Open Chrome driver”);
    test.log(Status.INFO, “Test case execution is started”);

    driver = new ChromeDriver();
    test.log(Status.INFO, “Chrome Browser is open”);

    public void OpenGoogleurl() {

    test= extent.createTest(“TC_2 = Open Google url”);
    test.log(Status.PASS, “Google url is open”);

    public void Verifypagetitle() {

    test = extent.createTest(“TC_3= Verify the title of url”);
    String title = driver.getTitle();

    public void tearDown()


    public void checkresult(ITestResult testResults) {

    if(testResults.getStatus()==ITestResult.FAILURE) {
    test.log(Status.FAIL, “Test case is failed because”);
    test.log(Status.FAIL, testResults.getThrowable());
    } else if(testResults.getStatus()==ITestResult.SUCCESS) {
    test.log(Status.PASS, “Test case is passed”);
    } else if(testResults.getStatus()==ITestResult.SKIP) {
    test.log(Status.SKIP, testResults.getThrowable());


  10. Rahul says:

    Screenshots generated on extentreport gets blank/broken after sending the report to some other machine or to email. Is there any solution for this?

  1. October 19, 2016

    […] For extent report version 3.x, please follow Selenium reporting using extent report ver 3.x […]

Leave a Reply

Your email address will not be published. Required fields are marked *