Selenium : How to generate extent reports

Posted in Selenium By Raj On December 25, 2017


In this article,  I am going to showcase you how to generate extent reports in selenium, you can use TestNG reports to check status of test cases but those are not user-friendly, instead of that you can use Extent reports

If you are new to Selenium and don’t know how to use TestNG then I would recommend you to check this article

The first thing is you need to do is add below dependency in the POM.XML file 

Here, I am going to test search functionality of my blog and the code is something like below, and there are two test cases I have written Enter search text and Click on search button

I am using ExtentReports and ExtentTest classes, the ExtentReport class is used to generate a dashboard and the ExtentTest class is used for logging purpose

In the beforeSuite() method use below code to initialize extent HTML report, the false condition will not override the existing report instead of that it appends test cases with existing ones

You need to use below code for every test case to log test case entry in the extent HTML reports

The ITestResult result has FAILURE, SKIP, and SUCCESS status, based on the result we need to log the status in the extent reports using below-mentioned code

 You can configure the extent reports using below mentioned extent-config XML file 

Use below code in the beforeSuite() to load the above config file

Now, go to the Run -> Run As -> TestNG Test, you should see something like below in the reports dashboard

extent-reports-one extent-reports-two