How to Generate Extent Reports in Selenium
By Rohan Vats
Updated on Dec 27, 2024 | 12 min read | 10.43K+ views
Share:
For working professionals
For fresh graduates
More
By Rohan Vats
Updated on Dec 27, 2024 | 12 min read | 10.43K+ views
Share:
Selenium provides frameworks like TestNG and JUnit, to provide inbuilt reports. Although these built-in extentreports in selenium offer information on all steps that get executed as a part of test cases, these need further customization for being shared with the main project stakeholders.
Extent report selenium is also a customizable variant of an HTML report which can get integrated into the Selenium WebDriver with the use of JUnit and the TestNG frameworks.
Check out our free courses to get an edge over the competition.
The tutorial guides on extent report in selenium you with a complete idea of how to generate Extent Reports in Selenium WebDrive with a few example codes.
The open-source library used for test automation in selenium is ExtentReports. Testing frameworks; NUnit, JUnit, etc can be integrated with the library. In-built reports are created in selenium through the frameworks of TestNG and JUnit, but Extent reports are still the first choice of the Automation testers of selenium. The extent reports in selenium give more insight into the execution of the automation scripts. The results are depicted as pie charts and are basically HTML documents. Are details like the snapshots, and custom logs can be generated through the library.
After the successful run of an automated test, a report of test execution is to be generated by the testers. A default report is provided by the TestNG, but the details are not provided. With the applicability of the ExtentReport API, interactive reports could be generated through simple configurations. Frameworks of Java and .Net such as JUnit, NUnit, and TestNG, etc. are supported by the library.
Check out upGrad’s Advanced Certification in Cloud Computing
Dependency of the extent report maven
The selenium extent reports consists of two classes:
1. ExtentReports class
The tester specifies a path and based on the path specified, HTML reports are generated from the ExtentReports class. Either there is the generation of a new report or the overwriting of an existing report. It is decided based on the Boolean value. The default Boolean value is “true” which means that there will be overwriting of all data that existed in the past.
Check out upGrad’s Advanced Certification in Blockchain
2. ExtentTest class
Test steps are logged through the ExtentTest class onto the HTML reports generated through the above method.
3. Extent HtmlReporter
An HTML file is created by this class.
The listed built-in functions can be used with classes that are listed below.
The following values are used to indicate the status of a test: PASS, SKIP, FAIL, and INFO.
There are a number of advantages of using extent report selenium. Here are some of them-
The extent reports in selenium contain a couple of major classes. These are used very frequently.
The syntax for the same is listed below-
ExtentReports reports = new ExtentReports(“Path of directory to store the resultant HTML file”, true/false);
ExtentTest test = reports.startTest(“TestName”);
Software Development Courses to upskill
Explore Software Development Courses for Career Progression
A few prerequisites for generating an extent report are:
Basic steps that are required to follow for the generation of extent reports are:
Explanation of the code
With the startTest method, the test execution begins. The object of extent reports is initialized. The extent report object uses any user-defined path as a parameter passed onto it.
@beforeclass: The use of the extent reports is demonstrated by the code.
@test: The following actions are automated through this class:
@afterclass: Code for the execution of a case of test postconditions are included in this class. It includes the code for the test ending or report flushing. Without the use of the method flush(), the extent reports in selenium won’t be generated.
Subscribe to upGrad's Newsletter
Join thousands of learners who receive useful tips
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.File);
File Dest = new File(“scr/../Errimages/” + System.currentTimeMillis()+ “.png”);
String errflpath = Dest,getAbsolutePath();
Fileutils.copyFile(scrFile, Dest);
returnerrflpath;
test.log(LogStatus.Fail,test.addScreenCapture(capture(driver))+ “Test Failed”);
upGrad’s Exclusive Software Development Webinar for you –
SAAS Business – What is So Different?
An example is shown to let you understand the process of generation of extent report maven.
Step 1: A maven project and a class is to be created BasicExtentReport.java with the addition of a code available here
Step 2: Passing the OS and parameters of the browser is done through creating a testng.xml file. The code is available on the mentioned website.
Step3: Another code is added to the pom.cml file.
Step4: Running the program generates the resulting report.
For viewing the failure reports, the failed tests are to be clicked. This will display the test status along with the reason for the test failure.
A few additional things related to extent reports are:
Learn Software Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.
For the generation of any customizable reports, the extent reports are the best way. Being an open-source library with an easy configuration with selenium, the extent reports have definitely become the best choice for all the automation testers. The article briefly discussed the extent reports, how to generate them, and their usefulness. The benefits can be reaped out through the knowledge of the software programming which is the basis of the generation of the extent reports.
Extent Reports are used popularly by automation testers in order to generate a test report and then share it ahead with stakeholders in an organization. As a test report plays a vital role in the process of automation, it is mostly better to have reports that are good. A good report is one that can capture completely a test execution summary along with a graphical representation.
Extent Reports don’t just provide a detailed summary of any executed tests but these also provide add-on pie charts for the depiction of test summary in a visual format.
Additionally, it is easy to replace any present reporting tool when you employ Extent Reports in the automation frameworks. Extent Report is indeed a very simple thing, yet it provides extraordinary reports. You can now use the above information to integrate a reporting tool into the automation framework minus any hurdles. Try hands-on Extent Reports in Selenium and keep exploring!
If you are willing to learn and explore the benefits of software programming, check the course of Executive PG Programme in Software Development – Specialisation in Full Stack Development, offered by upGrad. This is a specially designed course for entry-level professionals within the age group of 21 to 45 years. Providing a platform for online lectures and interactive sessions with hands-on experiences, the course provides placement assurance in top industries. Our team is available for any queries.
Selenium Report Builder or Selenium IDE is a Firefox plugin for Selenium which helps to create and edit the Selenium test cases. It makes the automation process to be more efficient and reduces the effort needed to create different reports. It is a comfortable way to run tests and provides an overview of the current status. Reports are generated in various formats such as text, PDF, CSV, HTML etc.
Selenium is a tool for automating web applications for testing purposes, and can be used for regression testing. Selenium can automate anything a user can do in a browser. Most websites have some kind of functionality that makes it easier for their employees to accomplish tasks like ordering inventory, processing orders, updating the website, etc. Selenium can be used to test web-based applications and websites. It is a high-level language which supports various programming languages like JAVA and C#. Selenium is used to automate browser and provides web application developers with the ability to write automated tests to be run against web applications.
Selenium Grid is a tool that allows running automated tests across several browsers (or other grid nodes). It allows for parallel execution of these tests with several configurations (locations, browsers, operating systems) and several browsers at once. The tests themselves can be run in headless mode so as to not require any GUI at all. The Grid offers asynchronous job execution and is capable of managing hundreds of jobs concurrently. Selenium grid is thus a hub and spoke model for running test cases. Grid allows users to pool multiple browsers to run a single test case. Once set up, it can be used to run tests across multiple machines or browsers on demand or on a schedule. Selenium Grid can be used to parallelize test execution, scale testing and increase test coverage.
408 articles published
Rohan Vats is a Senior Engineering Manager with over a decade of experience in building scalable frontend architectures and leading high-performing engineering teams. Holding a B.Tech in Computer Scie...
Get Free Consultation
By submitting, I accept the T&C and
Privacy Policy
India’s #1 Tech University
Executive PG Certification in AI-Powered Full Stack Development
77%
seats filled
Top Resources