Selenium WebDriver Reporting – Extent Reports
As we all familiar with different types of reporting Tools like XSLT Reporting,Allure Reporting mentioned below:
XSLT Report: http://total-qa.com/generate-xslt-report-ant-build/
Allure Report: http://total-qa.com/advanced-selenium/allure-reporting/
We will explore a new open source reporting tool Extent Reports in selenium webdriver.
Extent Reports is a logger-style API written for Java and .NET environments which allows creating HTML reports from tests.
-
Steps to Configure Extent Reports:
- Access the link extent reports for maven dependency information
- Create a maven project add the extent reports dependency.
- Create a Sample Program to generate extent reports.
- Execute the program verify the extent.html file generated in the project.
1 2 3 4 5 6 7 8 9 10 11 |
<!-- pom.xml --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>3.1.3</version> </dependency> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
package org.totalqa.extentreports; import java.io.IOException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.Assert; import org.testng.annotations.Test; import com.aventstack.extentreports.ExtentReports; import com.aventstack.extentreports.ExtentTest; import com.aventstack.extentreports.MediaEntityBuilder; import com.aventstack.extentreports.Status; import com.aventstack.extentreports.reporter.ExtentHtmlReporter; /** * * @author Total-QA * */ public class ExtentReportsEx { WebDriver driver; @Test public void verifyHomePageTitle() throws IOException { ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("extent.html"); // create ExtentReports and attach reporter(s) ExtentReports extent = new ExtentReports(); extent.attachReporter(htmlReporter); // creates a toggle for the given test, adds all log events under it ExtentTest test = extent.createTest("verifyHomePageTitle", "Checking the Title"); driver = new ChromeDriver(); // log(Status, details) test.log(Status.INFO, "Chrome Browser Launched Successfully"); driver.get("http://total-qa.com"); test.log(Status.INFO,"Navigated to URL"); String actual = driver.getTitle(); test.log(Status.INFO, "Actual Title returned :: " + actual); String expected = "TotalQA - Future of Software Testing"; test.log(Status.INFO, "Expected Title returned:: "+ expected); Assert.assertEquals(actual,expected); // log with snapshot test.pass("details", MediaEntityBuilder.createScreenCaptureFromPath("screenshot.png").build()); // test with snapshot test.addScreenCaptureFromPath("screenshot.png"); // calling flush writes everything to the log file extent.flush(); } } |
this code is not working in my selenium. its not creating any folder or file so save report. i have downloaded extentreports-java-3.1.5 version so is it a version problem or what?
Might be an issue. Could you please try with version mention in this post and check.
This code does not include extent report generation