How to Generate Extent Reports in Selenium Webdriver?


ExtentReports is an open-source reporting library used in selenium test automation. 


Add ExtentReports library in pom.xml


<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->

<dependency>

    <groupId>com.aventstack</groupId>

    <artifactId>extentreports</artifactId>

    <version>4.0.9</version>

</dependency>



Pre-requisites to Generate Extent Reports:

  1. Java should be installed 
  2. TestNG should be installed 
  3. Extent Report Jars 
  4. extent-config.xml – It allows to configure HTML Report


Steps to execute extent reports


@Test

public void reports() throws InterruptedException {

ExtentHtmlReporter reporters = new ExtentHtmlReporter("/Users/uss/Desktop/untitled folder/GenerateReports/src/main/java/utility/report.html");

ExtentReports reports = new ExtentReports();

reports.attachReporter(reporters);

ExtentTest Test = reports.createTest(this.getClass().getSimpleName());

Test.log(Status.INFO, "Info msg");

Thread.sleep(1000);

Test.log(Status.PASS, "Success message");

Thread.sleep(10000);

Test.log(Status.FAIL, "Failed message");

Thread.sleep(10000);

Test.log(Status.FATAL, "Fatal error");

Thread.sleep(10000);

reports.flush();

}

@Test

public static ExtentHtmlReporter reporter = new ExtentHtmlReporter(System.getProperty("user.dir") + "/src/test/java/reports/TestReport.html");

public static ExtentReports reports = new ExtentReports();

public static ExtentTest test;


public void reports() throws InterruptedException {


test = reports.createTest(this.getClass().getSimpleName());

reports.setSystemInfo("Environment", "Production");

reports.setSystemInfo("Tester Name", "Unicode");

reports.attachReporter(reporter);

test.log(Status.INFO, “Info msg”);

}

Comments

Popular posts from this blog

For Get Dynamic data & USe it into Postman Body parameters

API Automation Testing Script to check Response

Login through Data Driven Testing in selenium

Which dependencies needed in pom.xml while doing automation through selenium?

Download Java(JDK) & Eclipse IDE for selenium

What is data driven testing?

How to extract all the links in selenium?