How to Generate Extent Reports in Selenium Webdriver [2025 Update]
Guide To Generate Extent Reports In Selenium WebDriver i.e., Extent Spark Reporter (Extent Reports Version 5)
In this article, we see one of the most popular and widely used Selenium Reporting Tools (Extent Reports). Selenium Results can be seen using different Selenium Reporting tools. Some of the Selenium WebDriver Reporting tools are as follows.
- Selenium TestNG Report Generation
- Selenium JUnit Report Generation
- Selenium Extent Reports (Most Popular Report)
What are the Extent Reports?
ExtentReports is an open-source reporting library used in selenium test automation. Extent reports become the first choice of Selenium Automation Testers, even though Selenium comes with inbuilt reports using frameworks like JUnit and TestNG. With extent reports, you can offer a more extensive and insightful perspective on the execution of your automation scripts. So let’s see why Automation testers prefer Extent reports to others.
Advantages of Extent Reports
Some of the advantages of Extent Reports are as follows
- Extent reports are more customizable than others.
- Captures screenshots at every test step
- Displays the time taken for test case execution within the report.
- Extent API can produce more interactive reports, a dashboard view, graphical view, and emailable reports
- You can easily track multiple test case runs that occur within a single suite.
- It can be easily integrated with frameworks like JUnit, NUnit, & TestNG
Using Extent Reports in Selenium Webdriver
Extent Reports in Selenium contain two major classes that are used frequently.
- ExtentReports class
- ExtentTest class
Syntax
ExtentReports reports = new ExtentReports("Path of directory to store the resultant HTML file", true/false);
ExtentTest test = reports.startTest("TestName");
The ExtentReports class is used to generate an HTML reports based on a path specified by the user. The Boolean flag decides whether the existing report has to be overwritten or a new report must be generated. Value ‘true’ is the default value, meaning that all the existing data will be overwritten.
The ExtentTest class is used to log test steps on the previously generated HTML report.
Both the above classes can be used with the frequently used built-in methods that are listed below.
- startTest: Used to execute preconditions of a test case
- endTest: Used to execute postconditions of a test case
- Log: Used to log the status of each test step onto the resultant HTML report.
- Flush: Used to erase any previous data on the relevant report and create a whole new report
Test Status can be indicated by the following values:
- PASS
- FAIL
- SKIP
- INFO
Syntax
reports.endTest();
test.log(LogStatus.PASS,"Test Passed");
test.log(LogStatus.FAIL,"Test Failed");
test.log(LogStatus.SKIP,"Test Skipped");
test.log(LogStatus.INFO,"Test Info");
The Log method takes in two parameters, the first being the test status and the second being the message to be printed onto the resultant report.
Generating Extent Reports In Selenium WebDriver
The main scope of this article is to show the Extent Reports. This is the most popular and widely used Selenium Reporting tool in the current market.
Let’s see how to generate extent reports in Selenium WebDriver.
Pre-requisites to Generate Extent Reports
- Java should be installed – Install and setup Java
- TestNG should be installed – Install TestNG
- Extent Report Jars – (Version 5.0.9)
- extent-config.xml – It allows to configure HTML Report
Steps To Generate Extent Reports
Step #1: Firstly, create a TestNG project in eclipse
Step #2: Download extent library files (Extent reports Version 5 JAR file – Extent Spark Reporter) and add the downloaded library files to your project
If you are using pom.xml file then you can add Extent Reports Maven dependency 5.0.9 in your maven project.
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.9</version>
</dependency>
Step #3: Create a java class say ‘ExtentReportsClass’ and add the following code to it
Selenium Continuous Integration With Jenkins [Maven – Git – Jenkins]
Code to validate title and logo on Google home page.
Given clear explanation in the comments section with in the program itself. Please go through it to understand the flow.
package myExtentReport;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.*;
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.ExtentSparkReporter;
import com.aventstack.extentreports.reporter.configuration.ChartLocation;
import com.aventstack.extentreports.reporter.configuration.Theme;
public class ExtentReportsClass {
public WebDriver driver;
public ExtentSparkReporter spark;
public ExtentReports extent;
public ExtentTest logger;
@BeforeTest
public void startReport() {
// Create an object of Extent Reports
extent = new ExtentReports();
spark = new ExtentSparkReporter(System.getProperty("user.dir") + "/test-output/STMExtentReport.html");
extent.attachReporter(spark);
extent.setSystemInfo("Host Name", "SoftwareTestingMaterial");
extent.setSystemInfo("Environment", "Production");
extent.setSystemInfo("User Name", "Rajkumar SM");
spark.config().setDocumentTitle("Title of the Report Comes here ");
// Name of the report
spark.config().setReportName("Name of the Report Comes here ");
// Dark Theme
spark.config().setTheme(Theme.STANDARD);
}
//This method is to capture the screenshot and return the path of the screenshot.
public static String getScreenShot(WebDriver driver, String screenshotName) throws IOException {
String dateName = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
TakesScreenshot ts = (TakesScreenshot) driver;
File source = ts.getScreenshotAs(OutputType.FILE);
// after execution, you could see a folder "FailedTestsScreenshots" under src folder
String destination = System.getProperty("user.dir") + "/Screenshots/" + screenshotName + dateName + ".png";
File finalDestination = new File(destination);
FileUtils.copyFile(source, finalDestination);
return destination;
}
@BeforeMethod
public void setup() {
System.setProperty("webdriver.chrome.driver","C://AutomationFramework//Drivers//chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/");
}
@Test
public void verifyTitle() {
logger = extent.createTest("To verify Google Title");
Assert.assertEquals(driver.getTitle(),"Google");
}
@Test
public void verifyLogo() {
logger = extent.createTest("To verify Google Logo");
boolean img = driver.findElement(By.xpath("//img[@id='hplogo']")).isDisplayed();
logger.createNode("Image is Present");
Assert.assertTrue(img);
logger.createNode("Image is not Present");
Assert.assertFalse(img);
}
@AfterMethod
public void getResult(ITestResult result) throws Exception{
if(result.getStatus() == ITestResult.FAILURE){
//MarkupHelper is used to display the output in different colors
logger.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + " - Test Case Failed", ExtentColor.RED));
logger.log(Status.FAIL, MarkupHelper.createLabel(result.getThrowable() + " - Test Case Failed", ExtentColor.RED));
//To capture screenshot path and store the path of the screenshot in the string "screenshotPath"
//We do pass the path captured by this method in to the extent reports using "logger.addScreenCapture" method.
//String Scrnshot=TakeScreenshot.captuerScreenshot(driver,"TestCaseFailed");
String screenshotPath = getScreenShot(driver, result.getName());
//To add it in the extent report
logger.fail("Test Case Failed Snapshot is below " + logger.addScreenCaptureFromPath(screenshotPath));
}
else if(result.getStatus() == ITestResult.SKIP){
logger.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + " - Test Case Skipped", ExtentColor.ORANGE));
}
else if(result.getStatus() == ITestResult.SUCCESS)
{
logger.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" Test Case PASSED", ExtentColor.GREEN));
}
driver.quit();
}
@AfterTest
public void endReport() {
extent.flush();
}
}
extent-config.xml:
<?xml version="1.0" encoding="UTF-8"?> <extentreports> <configuration> <!-- report theme --> <!-- standard, dark --> <theme>standard</theme> <!-- document encoding --> <!-- defaults to UTF-8 --> <encoding>UTF-8</encoding> <!-- protocol for script and stylesheets --> <!-- defaults to https --> <protocol>https</protocol> <!-- title of the document --> <documentTitle>ExtentReports 2.0</documentTitle> <!-- report name - displayed at top-nav --> <reportName></reportName> <!-- report headline - displayed at top-nav, after reportHeadline --> <reportHeadline>Automation Report</reportHeadline> <!-- global date format override --> <!-- defaults to yyyy-MM-dd --> <dateFormat>yyyy-MM-dd</dateFormat> <!-- global time format override --> <!-- defaults to HH:mm:ss --> <timeFormat>HH:mm:ss</timeFormat> <!-- custom javascript --> <scripts> <![CDATA[ $(document).ready(function() { }); ]]> </scripts> <!-- custom styles --> <styles> <![CDATA[ ]]> </styles> </configuration> </extentreports>
By using this external XML file (extent-config.xml), we could change the details such as Report Theme (either standard or dark), Report Title, Document Title etc.,
Console Output:
==============================================
Default suite
Total tests run: 2, Failures: 1, Skips: 0 ==============================================
Refresh the project after execution of above ExtentReportsClass.java file. You could find an HTML file named “STMExtentReport.html” in your test-output folder. Copy the location of the STMExtentReport.html file and open it by using any browser. You could see beautiful high rich HTML reports as shown below.
Code Explanation
i. Imported two classes ExtentReports and ExtentTest.
ExtentReports: By using this class we set the path where our reports need to generate.
ExtentTest: By using this class we could generate the logs in the report.
ii. Took two methods with @Test annotation such as verifyTitle, VerifyLogo. another method startReport with @BeforeTest annotation, another method endReport with @AfterTest annotation, another method getResult with @AfterMethod annotation, and another method setup with @BeforeMethod annotation.
Here my intention is to generate a report with all the three types of results such as Pass, and Fail.
iii. Used object of ExtentReports class (i.e., extent) in the startReport method which was assigned to @BeforeTest annotation to generate the HTML report in the required path
iv. Used object of ExtentTest class (i.e., logger) in the remaining methods to write logs in the report.
v. Used ITestResult class in the @AfterMethod to describes the result of a test.
Extent Spark Reporter | Graphical Report with PIE Charts (Sample reports)
TestCases
Exceptions
Tags
Device
Author
Graphical Report
Images source: ExtentReports.com
Check the below video to see “Extent Reports Complete Guide“
If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.
Wrapping up
Generating reports is a key part of any automation framework. Reports give you visibility into the health of your automation tests and can help you identify areas where improvements are needed.
There are many different options for generating reports, but one of the most popular is using the Extent Reports.
Extent reports is an open-source library that generates customizable HTML reports. So it becomes the best choice of Selenium Automation Testers to generate test reports and share them with the stakeholders in the organization.
In addition to outlining all the executed tests, Extent Reports also provide pie charts that visually summarize the test scripts.
If you are not a regular reader of SoftwareTestingMaterial.com then I highly recommend you to signup for the free email newsletter using the below form.
FAQ’s
Can we customize extent reports?
Yes, we can customize extent reports like change the title, change to dark theme, add screenshots, include logo and others
How to change title in the extent reports?
Open your file “extent-config.xml” and add the below code to it.
Modify the browser title between ‘documentTitle’ open and closed tags.
Modify the report title between ‘reportName’ open and closed tags.
How to change the theme to dark theme?
Open your XML file and add the below code under the configuration node.
Modify the theme as ‘dark’ between ‘theme’ open and closed tags.
How to resolve HTTPS protocol error in extent reports?
Sometimes HTTPS protocol of style sheets and script files are blocked due to network restrictions in organizations.
In this case, we can add the below code under the configuration node of your XML file to ensure all the scripts and style sheets follow the HTTP protocol
Modify the text as ‘http‘ between ‘protocol’ open and closed tags.
What is the use of extent reports?
Extent Reports is an easy-to-use library that allows users to create custom reports, whether they pertain to test runs or other projects.
Is extent report part of TestNG?
Extent reports are HTML-based, customizable reports that come equipped with Selenium using the TestNG framework. Not only does it allow customers to create a plethora of data-driven reports, but also generate documents and XML feeds that can handle complex actions and make decisive decisions.
If i have one @Test method..then how can i get pass fail or skipped result using ITestresult.
Hi Satya, Result will be displayed based on @AfterMethod. I just took If and else if. You could mention another else if for pass condition. Result will be displayed based on the result of the test case.
Hi Rajkumar,
Can we append extra information like displaying some project variables which will be useful for analysis purpose, where user will go through report only instead of log file
Regards,
Shruti
Hi Shruti, try this..
logger.log(LogStatus.INFO, "Your_Message")
Hi Rajkumar,
I have a task related to reporting in testng and need your help in deciding the approach. Basically we want to see in reports all the assertions that are used in a test method. In our present framework we do get the test result populating which all methods are passed/failed in a java class , in addition to it now we want to display the assertions(Pass or Fail) which are written inside those method in the HTML report.
Many thanks in advance
Hi Reetanshu, could you pls give me more info. Try LogStatus.PASS, .FAIL, .SKIP, .INFO after assertion.
Hi Rajakumar,
Thanks for the reply , I was also thinking the same to write some wrapper with logging around Testng assertions . Just wanted to check if any advance report like extent report generates details including assertion inside a particular methods in report layout. I am expecting output in below format, let me know if you need more information.
Current Tests reults
Duration Passed Skipped Failed Pass Rate
Test Class 1 0.158s 2 0 0 100%
Test Class 2 0.156s 1 0 0 100%
Test class 3 0.598s 1 0 0 100%
Total 4 0 0 100
Expected Test result
Test Class 1
Method 1 Passed Skipped Failed
Assert Equal-“validation name” 1 0 0
Assert True-“Validation name 1 0 0
Assert False-“Validation Name” 0 0 1
Method2
Assert Equal-“validation name”
Assert True-“Validation name
Assert False-“Validation Name”
Hi Reetanshu, I have gone through extent report documentation to include assertions in the report but no luck. I guess, it’s better to move on with logs around assertions. Thanks.
Hi Rajkumar, Its not possible. May be in the later version they may release this. By the way, how could i add screenshots in the extent reports.
Thanks in advance Rajkumar.
Hi Divya,
This link will guide you on how to capture screenshots and include it in the extent reports.
Hey Dear My TestNG Report is showing Broken UI, Not including inline css, am not using jenkins ,just creating simple project in TestNG and using Extent Report, plz help me
Hi Abida,
Could u give me more info..
how we can see offline the extent report ?
Hi Rajkumar,
Many thanks for the information, will use logging around assertions.
Hi Rajkumar,
When using extent reports with screenshots, I am seeing few places, screenshots are getting misplaced. So how can we avoid that?
Any suggestions are welcome.
Hi Naveen, Could you please give me more information. Misplaced means? You could place your screencapture method whereever you required. It may be due to synchronization issue. Place some waits to capture screenshot of the right page.
Hi Raj,
Misplaced in the sense – Expected page screenshot is displayed in other place. E.g Login screenshot appeared after the login successful in the reports. This supposed to be present in the login section
This might be due to synchronization issue, let me add few more wait and will see how the results are getting generated.
Thanks for your input.
Hi Naveen, that sounds great. Try it and let me know if it works.
Do I need to implement this in every test cases? can’t it be modularize and invoke in each test cases. PLease reply soon
Hi Ayan, keep everything in your utility class and call ‘logger.log’ wherever you feel necessary in your tests.
do you mean as per your example “extendreportsclass” should be written within utility class and call whenevr needed? Sorry to bother you by such silly qs, but as I am very new in this automation domain, can you please share some code snippet for the same, it will be helpful.
As of now, i have implemented multiple testcases with testng integration.
awaiting for your kind reply, please help how to call it from main testcases class.
Hi Ayan, Place these (@BeforeTest, @AfterMethod and @AfterTest of extent reports..) in your Base class and call (logger = extent.startTest(“your test name goes here”)) in your tests..
if any test fails, @AfterMethod will be called and dispalys the message in the report.
HI
I want to use this in multiple test cases? do I need to implement this in all test cases separately? or there is a way to modularize the same and implement this by calling the methods.
you can capture assert failure in Extent report as well. We have implemented in your project. try to use your code in try catch block and in catch block capture the fail status.
for ex
}
catch (Throwable t) {
test.log(LogStatus.FAIL, t);
throw t;
}
}
@After
public void afterTest() throws Throwable {
try{
new NbnLoginPage().logout_maximo();
new Page().ScreenshotToPDf(getClass().getSimpleName());
endTest();
}catch(Exception e)
{
System.out.println(“Some issue in closing test “);
}
}
how to get bulk test results in one tab in extend report?
how to get bulk test results in one tab in extend report? like one tab in right side and one tab in left side and i want 10 test results?
Hi Mamatha, could you please give me more info on what you are expecting.
Hi, can you please tell me, how to generate a report for all tests which I have created via PageObject. I have a few test classes and pages. I have one functional/base page class, where I setup chrome driver and open a specific page, after that every test continue. Not start from the beggining. When I add your methods (@BeforeTest, @AfterMethod and @AfterTest) only to fuctional class, I got null pointer exception. Only when I add into every Test class every @annotation, test is runned. (I add also logger in the beggining of the tests, and status.passed in the end of the test, in both cases)
And one more question, when I run through terminal all tests, with command mvn clean verify, I get report for only last Test class which has for e.g. 5 tests, nothing before that, ,even I have about 30 tests. Is possible to get report for all of them when they are runned on this way?
Thank you very much
Hi Sandra, Keep @BeforeTest, @AfterMethod, @AfterTest in your base class. Call this statement(logger = extent.startTest(“Your_Test_Case_Name”);) inside @Test method in your tests. If you still have any issues, pls let me know.
Hi Rajkumar, when I leave that in the base class and not in the test class (and add only logger = extent.startTest(“Your_Test_Case_Name”);) inside @Test method), after run test fails in the beggining and I get this error:
Test fail.
Tests run: 3, Failures: 2, Errors: 0, Skipped: 1, Time elapsed: 18.52 sec <<< FAILURE! – in com.axonista.tests.AccountsTest
checkRemocoVisibilityBetweenChannels
(com.axonista.tests.AccountsTest) Time elapsed: 0.009 sec <<< FAILURE!
java.lang.NullPointerException
at com.axonista.tests.AccountsTest.
checkRemocoVisibilityBetweenChannels(AccountsTest.java:89)
generateReport(com.axonista.tests.AccountsTest) Time elapsed: 0.01 sec <<FuctionalTest.generateReport:97 » NullPointer
can you please help me?
Hi Could you please share your code to this rajkumarsmonline [at] gmail [dot] com
Hi,
Can u share any project you might have by chance which u made use of selenium using java for automating any web application?
regards,
ani
How to clear the content of previous run cases from extent report.
Hi Jitesh Bhojwani, Make it false.
extent = new ExtentReports (System.getProperty("user.dir") +"/EverjobsExtentReport.html", false);
Hi,
I am facing this issues “Cannot instantiate the type ExtentReports”
In this line “extent = new ExtentReports (System.getProperty(“user.dir”) +”/ExtentReport.html”, true);”
it show’s this “Cannot instantiate the type ExtentReports” error.
Share your code, I will look into it Rakesh
Hi
I have fixed above issues.
But i am not get the extent reports.
here is code:
“extent = new ExtentReports (System.getProperty(“user.dir”) +”/test-output/STMExtentReport.html”, true);”
in test-output folder i am not able to see this “STMExtentReport.html” file.
Hi!
How can I add some dynamic data into this config?
Say, I would like to have execution date in documentTitle tag .
How should it look?
Hello, did anyone ever try to upload their reports inside JIRA?
Looks like JIRA does not allow html format.
How do you guys upload your reports? Do you just email your reports?
I would like to be able to upload my automation report inside JIRA ticket. Is it possible? Did anyone ever tried to upload their reports inside JIRA?
Thank you in advanced.
Hey Hi Raj – Great Article ..! Thanks for your time for this .
Actually i followed same steps , but i struck on 2 things …
Major one :
When I’m running my scripts in a sequence I can able to run successfully & Im getting results too. When I’m running the same tests/methods/classes in parallel, all my Extent reports are getting messed up (one test logs are mixed into another test logs) and failing.For my tests, Im using Selenium with TestNG, Maven & Im running my tests in Sauce labs.
Second one :
I am calling Close() method in @AfterClass as i want to execute all my test but its throwing me the error close called before it self stating and all the tests are failing
Can you please throw some light on this.
Thanks ,Chaithanya
Hi Chaithanya,
I am struggling with the same issue. If you have found any solution then pls forward to me also.
It will highly appreciated.
Many thanks in advance.
Hey Rajkumar,
I am trying to figure out how can I insert multiple test reports into 1 mega report. So, this is how my testng.xml looks like:
Currently I am flushing the report in @AfterSuite, but I am facing the problem when the tests (testng.xml test node) fail, @AfterSuite does not run and the report is not generated.
I was thinking to flush reports in @AfterTest, and then put all test reports in 1 mega report. Is this doable?
I want report to look something like: http://relevantcodes.com/Tools/ExtentReports2/ExtentMerge.html#
I am using:
Selenium Webdriver, TestNG, Java, Extent Report 2
Thanks,
Jigs
Hi Jigs,
Make it false in the below line of code and try it once.
Mentioned in the blog.
extent = new ExtentReports (System.getProperty("user.dir") +"/test-output/STMExtentReport.html", true);
Modify it as below:
extent = new ExtentReports (System.getProperty("user.dir") +"/test-output/STMExtentReport.html", false);
Hi Raj Kumar,
Very well explained. I was able to implement extent reports in my project successfully with the help of this tutorial. Great job. Awesome. Thank you very much!!!
Thanks for your kind words Alok Sharma.
Hi
Any idea about how to make Jenkins send the html file over the mail along with css and other dependencies ?
How to enable Content Security Policy in Jenkins (installed in tomcat).
how testcase file are being fetched in the report. i mean in code where it is mentioned???
Hi there, didnt get you.
How can i implement this Extent report in my project ? I tried and created the same “Testing material” package with all the above steps mentioned in my project. But whenever i run my project and refresh the project , the “STMExtentReport.html” under “test-output” shows the “Total tests run: 3, Failures: 1, Skips: 1” report (your project) and not my actual project report. What should i do so that my actual project test execution report gets reflect in “STMExtentReport.html”.
Hi, refresh the project to see the report.
What is the path you have given here
extent = new ExtentReports (System.getProperty("user.dir") +"/test-output/STMExtentReport.html", true);
Try to change the path and see.. Hope you know, you could create a new folder in your project. If you any other queries, please let me know.
Hi Rajkumar, i tried with changing the path, but same results. I created the folder “Reports_Extent” under my project. Below is the path which i tried.
extent = new ExtentReports (System.getProperty(“user.dir”) +”/Reports_Extent/STMExtentReport.html” ,true);
appreciate your help Sir !!
Hi, Share your project to rajkumarsmonline [at] gmail [dot] com
Hi, Great Article,however m getting an exception that close was called before test could end safely using endtest.
Hi Prateek, can you give me more info..
Hi Raj,
I have implemented the extent reports in my sample projects with three classes.
Running the testNG.xml file as TestNGSuite
First class contains
1. @Beforesuite and i have placed the extent part which you provided,
2. @Test method to launch browser
3. @AfterMethod and placed all the getresult method code
4. @AfterSuite and added flush & close.
Second class contains
1..@Test method to fill one text box value
Third class contains
1..@Test method to fill the same text box value
finally i am getting the reports as 1 Test passed and 2 Test failed with the below error for two times
com.relevantcodes.extentreports.ExtentTestInterruptedException: Close was called before test could end safely using EndTest.
at com.relevantcodes.extentreports.Report.terminate(Report.java:425)
at com.relevantcodes.extentreports.ExtentReports.close(ExtentReports.java:915)
at ngsuite.FirstClass.afterSuite(FirstClass.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:329)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Could you please help me to resolve the issue
Share your code to rajkumarsmonline@gmail.com
I have sent the code to your email id. Could you please check and let me know if you need further details
Hi Saravana,
Do the following changes and try it again.
1. @BeforeTest annotation to the method startReport
2. @AfterTest annotation to the method endReport
3. use this statement in the method launch
logger = extent.startTest("Class 1");
Hi Raj,
Thank you for the inputs. Could you please provide me the update for the below query,
1.. do i need to add @BeforeTest and @AfterTest instead of @Beforesuite&@Aftersuites.
2. I have added logger=extent.startTest(“Class1”)
Thank you in Advance
For the point 1 – yes. You have to change @AfterSuite to @AfterTest and @BeforeSuite to @BeforeTest
Hi Raj,
Thanks for wonderful video
Reports are not generation for me, i am getting below warning
WARNING: Unable to perform report configuration. The file C:\Users\aroy\workspace\CirtTrial\null\extent-config.xml was not found.
Please help
Thanks
Abhijith
Hi Abhijith, place extent-config.xml file in the following location
C:\Users\aroy\workspace\CirtTrial\null\extent-config.xml
Hii sir,
Can u please help me in explaining how can i save folder to desktop which should contain all the test reports.How to generate folder to save report in computer
Reply soon
Execute the script and refresh the project. You can see the reports folder under your project like ‘test-output’. Right click on that go to properties to find the path.
Hi Raj,
Is it possible to add the extent report into non testNG project.
Hi Raj,
(1) I implemented extent reports in my projects with multiple classes and several methods, is it possible to add the className at the beginning of the methods in a that class.
(2) After building on jerkins and generate extent report, how can it auto send reports as email to different recipients?
Thank you.
Regards.
hi,
following error thrown after adding the code.
java.lang.NoClassDefFoundError: freemarker/template/TemplateModelException
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:86)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:375)
at ExtentReport.ExtentReportsClass.startReport(ExtentReportsClass.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:515)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:216)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:143)
at org.testng.TestRunner.beforeRun(TestRunner.java:631)
at org.testng.TestRunner.run(TestRunner.java:599)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.ClassNotFoundException: freemarker.template.TemplateModelException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 26 more
Hi Rubin, Copy the exact code which I placed in this post and try to execute it. If it works, then modify your script as per your requirement.
I am facing same error, I am using test ng to create test cases. I used two classes first one where we start the selenium webdirver under Before test method(where I put the above mentioned code just before the selenium code.)
Second is test cases class where I put all test cases.
Second class inherits first class. the project was working before using extent.
please suggest.
Thank you,
Gaurav Arora
Hi Rajkumar,
can you help me out. I am getting Null pointer exception on
extent = new ExtentReports (System.getProperty(“/Users/abilash_babu/Desktop/output/Reportfinal.html”),true);
FAILED CONFIGURATION: @BeforeTest startReport
java.lang.NullPointerException
at java.base/java.io.File.(File.java:276)
at com.relevantcodes.extentreports.Report.setFilePath(Report.java:523)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:78)
at com.relevantcodes.extentreports.ExtentReports.(ExtentReports.java:373)
at ExportTestPlan.TestReports.startReport(TestReports.java:31)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.TestRunner.beforeRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:616)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
SKIPPED CONFIGURATION: @AfterMethod getResult
SKIPPED CONFIGURATION: @AfterMethod getResult
SKIPPED CONFIGURATION: @AfterMethod getResult
SKIPPED CONFIGURATION: @AfterTest endReport
SKIPPED: failTest
SKIPPED: passTest
SKIPPED: skipTest
===============================================
Default test
Tests run: 3, Failures: 0, Skips: 3
Configuration Failures: 1, Skips: 4
===============================================
Hi Abilash, Error message says the file name you provided is null. Please check it out again. Copy the exact code which I placed in this post and try to execute it. If it works, then modify as per your requirement.
Hi,
I have downloaded and added the extent reports library to my project. but I am not able to import the extent report package when I am writing ExtentReports extentl;.
hovering mouse over doesn’t showing any thing related to extent libraries.
Please suggest
Please check which version of extent jars you are using. If you are using latest version then follow this post.
even i am facing same issue …. 🙁
Very well explained. Liked it.
hii guys.how to generate pdf file in selenium automation code.if you know please tell me guys