Selenium Webdriver Appium Complete TutorialSelenium Webdriver Appium Complete Tutorial
Automation Testing
  • Tools
    • Selenium
      • Selenium Java Tutorial
      • Selenium C# Tutorial
    • Appium
      • Appium Java Tutorial
      • Appium C#Tutorial
    • Katalon
  • Trainings
  • TestNG
  • Reports
    • Extent Reports
      • Extent Reports – Java
      • Extent Reports – Java -Version3
      • Extent Reports – C#
    • Vigo Reports
    • AT Excel Report
  • Excel
    • Apache POI – Java
    • Excel With C#
  • Interview Questions
    • Selenium Interview Questions
    • Java Interview Questions
    • C# Interview Questions
  • Demo Site
  • Practice Site
  • More…
    • AutoIt
    • Sikuli
    • Robot Class
    • File Upload
    • ScreenShot
      • AShot
      • ShutterBug
  • About
February 23, 2017

Extent Reports Log Generation – Java – Version3





Extent Reports Log Generation will discuss about how to generate log steps in the Extent Reports. While running the test suite user want to log some information about the execution in the report. This information will help the user to understand the test step execution flow and any failures during the test suite execution.

By using Extent Reports we can generate logs in the HTML report. For this we need use the log() method of the ExtentTest Class. By using this method not only log the step information, we can provide the PASS, FAIL and SKIP information of the particular test case. To log the information we need to use the Status.INFO as first parameter in the log() method. And we need to use Status.PASS for the passed test case and Status.FAIL for the failed test cases.

Not only log the information in the report as plain text, along with this we can also apply some backgrounds to that information using Label concept in the extent reports. By using this we can apply different colours to the log information.

Below is the sample program for generating step logs in the report:

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.markuputils.ExtentColor;
import com.aventstack.extentreports.markuputils.MarkupHelper;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;

public class CreatingLogs
{
    ExtentHtmlReporter htmlReporter;
    ExtentReports extent;
    ExtentTest test;
    
    @BeforeTest
    public void config()
    {
        htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") +"/test-output/MyOwnReport.html");
        extent = new ExtentReports();
        extent.attachReporter(htmlReporter);
    }
    
    @Test
    public void logsGeneration()
    {
        test = extent.createTest("logsGeneration");
        test.log(Status.INFO,"createTest() method will return the ExtentTest object");
        test.log(Status.INFO, "I am in actual Test");
        test.log(Status.INFO, "We can write the actual test logic in this Test");
        
        // Using Labels
        test.log(Status.INFO, MarkupHelper.createLabel("*************** Using Labels ***************", ExtentColor.RED));
        test.log(Status.INFO, MarkupHelper.createLabel("This is Test Logger 1", ExtentColor.BLUE));
        test.log(Status.INFO, MarkupHelper.createLabel("This is Test Logger 2", ExtentColor.BLUE));
        test.log(Status.INFO, MarkupHelper.createLabel("This is Test Logger 3", ExtentColor.BLUE));
        test.log(Status.INFO, MarkupHelper.createLabel("This is Test Logger 4", ExtentColor.BLUE));
    }
    
    @AfterTest
    public void tearDown()
    {
        extent.flush();
    }
}

In the above program we have written so many test.log methods to log the information into the extent reports. This information will logged in the report with time stamp.





Below is the output/report of the above program.

 

Extent Report Logs

Please watch the YouTube video of this blog for better understanding.



Share this post: on Twitter on Facebook

Generating Extent Reports – Java – Version3 Capture Screenshot in Extent Reports – Java – Version3

Related Posts

GENERATE EXTENT REPORT WITH MULTIPLE CLASSES JAVA

Extent Reports-Java-Version3

Extent Report With Multiple Classes

Capture FullPage Screenshot in Extent Reports – Java

Extent Reports-Java-Version3

Capture FullPage Screenshot in Extent Reports – Java

CAPTURE SCREENSHOTS IN EXTENT REPORTS JAVA

Extent Reports-Java-Version3

Capture Screenshot in Extent Reports – Java – Version3

GENERATING EXTENT REPORTS JAVA-V3

Extent Reports-Java-Version3

Generating Extent Reports – Java – Version3

EXTENT REPORTS INTRODUCTION JAVA

Extent Reports-Java-Version3

Extent Reports Introduction – Java – Version3

Newsletter

Recent Posts

  • TAKING WEB ELEMENT SCREENSHOT IN SELENIUMHow to Capture WebElement Screenshot in Selenium Webdriver using selenium 4
    December 15, 2019
  • How To SWAP Two Numbers in Java Without using Temp VariableHow to SWAP Two Numbers in Java Without Temp variable or Without Third variable
    December 8, 2019
  • How to Swap Two Numbers in Java with Temp VariableHow to SWAP Two Numbers in Java using Temp Variable
    December 1, 2019
  • How to Read Properties file in JavaHow to Read Data From Properties File in Java
    November 27, 2019
  • Compare two arrays in java with out inbuilt functionsHow to Compare Two Arrays in Java without built-in functions
    November 16, 2019
© Selenium Webdriver Appium Complete Tutorial 2025