selenium-webdriverHTML Reports


This topic covers the creation of HTML reports for selenium tests. There are various types of plugins available for reporting and the widely used are Allure, ExtentReports and ReportNG.


This example covers the implementation of ExtentReports in Selenium using TestNG, Java and Maven.

ExtentReports are available in two versions, community and commercial. For the ease and demonstration purpose, we will be using community version.

1. Dependency

Add the dependency in your Maven pom.xml file for extent reports.


2. Configure plugins

Configure the maven surefire plugin as below in pom.xml

    <defaultGoal>clean test</defaultGoal>

3. Sample test with ExtentReports

Now, create a test with name

public class TestBase {
    WebDriver driver;

    ExtentReports extent;
    ExtentTest logger;
    ExtentHtmlReporter htmlReporter;
    String htmlReportPath = "C:\\Screenshots/MyOwnReport.html"; //Path for the HTML report to be saved

    public void setup(){
        htmlReporter = new ExtentHtmlReporter(htmlReportPath);
        extent = new ExtentReports();

        System.setProperty("", "pathto/chromedriver.exe");
        driver = new ChromeDriver();

    public void test1(){
        logger.log(Status.INFO, "Opened site");
        assertEquals(driver.getTitle()), "Google");
        logger.log(Status.PASS, "Google site loaded");

    public void getResult(ITestResult result) throws Exception {
        if (result.getStatus() == ITestResult.FAILURE)
            logger.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + " Test case FAILED due to below issues:", ExtentColor.RED));
        else if (result.getStatus() == ITestResult.SUCCESS)
            logger.log(Status.PASS, MarkupHelper.createLabel(result.getName() + " Test Case PASSED", ExtentColor.GREEN));
        else if (result.getStatus() == ITestResult.SKIP)
            logger.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + " Test Case SKIPPED", ExtentColor.BLUE));

    public void testend() throws Exception {

    public void tearDown() throws Exception {

Allure Reports

This example covers the implementation of Allure Reports in Selenium using TestNG, Java and Maven.

Maven Configuration


Add following code to configure the jcenter repository



Add following dependencies to your pom.xml


Surefire Plugin Configuration

        <groupId> org.apache.maven.plugins</groupId>

Sample test for Allure Report

Create a sample test with name

public class test{
    WebDriver driver;
    WebDriverWait wait;

    public void setup() {
        System.setProperty("", "path to/chromedriver.exe");
        driver = new ChromeDriver();
        wait = new WebDriverWait(driver,50);

    @Title("Title check")
    @Description("Checking the title of the loaded page.")
    public void searchTest(){
        String title = driver.getTitle();
        LogUtil.log("Title Fetched: "+title);
        LogUtil.log("Test Passed. Expected: Google | Actual: "+title);
        System.out.println("Page Loaded");

    public void teardown(){

In the above class we have used LogUtiil class. This is simply done to log Steps in our test. Below is the code for the same

public final class LogUtil {

    private LogUtil() {

    public static void log(final String message){
        //intentionally empty


@Title("") will add the title to your test in Allure Report

@Description("") will add the description to your test

@Step("") will add a step in the allure report for the test

On execution a xml file will be generated in the folder "target/allure-results/"

Final Report with Jenkins

If you are running in Jenkins with Allure Report plugin installed, then Jenkins will automatically render the report in your job.

Final Report without Jenkins

For those who dont have a Jenkins, use the following commandline to create the html report. Allure CLI is a Java application so it's available for all platforms. You have to manually install Java 1.7+ before using Allure CLI.


For Debian-based repositories we provide a PPA so the installation is straightforward: Install Allure CLI for debian

$ sudo apt-add-repository ppa:yandex-qatools/allure-framework
$ sudo apt-get update 
$ sudo apt-get install allure-commandline

Supported distributions are: Trusty and Precise. After installation you will have allure command available.

Mac OS

You can install Allure CLI via Homebrew.

$ brew tap qatools/formulas 
$ brew install allure-commandline

After installation you will have allure command available.

Windows and other Unix

  1. Download the latest version as zip archive from
  2. Unpack the archive to allure-commandline directory. Navigate to bin directory.
  3. Use allure.bat for Windows and allure for other Unix platforms.

In the Commandline/Terminal now simply enter following syntax and report will be generated into allure-report folder

$ allure generate directory-with-results/

enter image description here