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:
- Java should be installed
- TestNG should be installed
- Extent Report Jars
- 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
Post a Comment