
- Selenium - Home
- Selenium - Overview
- Selenium - Components
- Selenium - Automation Testing
- Selenium - Environment Setup
- Selenium - Remote Control
- Selenium - IDE Introduction
- Selenium - Features
- Selenium - Limitations
- Selenium - Installation
- Selenium - Creating Tests
- Selenium - Creating Script
- Selenium - Control Flow
- Selenium - Store Variables
- Selenium - Alerts & Popups
- Selenium - Selenese Commands
- Selenium - Actions Commands
- Selenium - Accessors Commands
- Selenium - Assertions Commands
- Selenium - Assert/Verify Methods
- Selenium - Locating Strategies
- Selenium - Script Debugging
- Selenium - Verification Points
- Selenium - Pattern Matching
- Selenium - JSON Data File
- Selenium - Browser Execution
- Selenium - User Extensions
- Selenium - Code Export
- Selenium - Emitting Code
- Selenium - JavaScript Functions
- Selenium - Plugins
- Selenium WebDriver Tutorial
- Selenium - Introduction
- Selenium WebDriver vs RC
- Selenium - Installation
- Selenium - First Test Script
- Selenium - Driver Sessions
- Selenium - Browser Options
- Selenium - Chrome Options
- Selenium - Edge Options
- Selenium - Firefox Options
- Selenium - Safari Options
- Selenium - Double Click
- Selenium - Right Click
- HTML Report in Python
- Handling Edit Boxes
- Selenium - Single Elements
- Selenium - Multiple Elements
- Selenium Web Elements
- Selenium - File Upload
- Selenium - Locator Strategies
- Selenium - Relative Locators
- Selenium - Finders
- Selenium - Find All Links
- Selenium - User Interactions
- Selenium - WebElement Commands
- Selenium - Browser Interactions
- Selenium - Browser Commands
- Selenium - Browser Navigation
- Selenium - Alerts & Popups
- Selenium - Handling Forms
- Selenium - Windows and Tabs
- Selenium - Handling Links
- Selenium - Input Boxes
- Selenium - Radio Button
- Selenium - Checkboxes
- Selenium - Dropdown Box
- Selenium - Handling IFrames
- Selenium - Handling Cookies
- Selenium - Date Time Picker
- Selenium - Dynamic Web Tables
- Selenium - Actions Class
- Selenium - Action Class
- Selenium - Keyboard Events
- Selenium - Key Up/Down
- Selenium - Copy and Paste
- Selenium - Handle Special Keys
- Selenium - Mouse Events
- Selenium - Drag and Drop
- Selenium - Pen Events
- Selenium - Scroll Operations
- Selenium - Waiting Strategies
- Selenium - Explicit/Implicit Wait
- Selenium - Support Features
- Selenium - Multi Select
- Selenium - Wait Support
- Selenium - Select Support
- Selenium - Color Support
- Selenium - ThreadGuard
- Selenium - Errors & Logging
- Selenium - Exception Handling
- Selenium - Miscellaneous
- Selenium - Handling Ajax Calls
- Selenium - JSON Data File
- Selenium - CSV Data File
- Selenium - Excel Data File
- Selenium - Cross Browser Testing
- Selenium - Multi Browser Testing
- Selenium - Multi Windows Testing
- Selenium - JavaScript Executor
- Selenium - Headless Execution
- Selenium - Capture Screenshots
- Selenium - Capture Videos
- Selenium - Page Object Model
- Selenium - Page Factory
- Selenium - Record & Playback
- Selenium - Frameworks
- Selenium - Browsing Context
- Selenium - DevTools
- Selenium Grid Tutorial
- Selenium - Overview
- Selenium - Architecture
- Selenium - Components
- Selenium - Configuration
- Selenium - Create Test Script
- Selenium - Test Execution
- Selenium - Endpoints
- Selenium - Customizing a Node
- Selenium Reporting Tools
- Selenium - Reporting Tools
- Selenium - TestNG
- Selenium - JUnit
- Selenium - Allure
- Selenium & other Technologies
- Selenium - Java Tutorial
- Selenium - Python Tutorial
- Selenium - C# Tutorial
- Selenium - Javascript Tutorial
- Selenium - Kotlin Tutorial
- Selenium - Ruby Tutorial
- Selenium - Maven & Jenkins
- Selenium - Database Testing
- Selenium - LogExpert Logging
- Selenium - Log4j Logging
- Selenium - Robot Framework
- Selenium - AutoIT
- Selenium - Flash Testing
- Selenium - Apache Ant
- Selenium - Github Tutorial
- Selenium - SoapUI
- Selenium - Cucumber
- Selenium - IntelliJ
- Selenium - XPath
- Selenium Miscellaneous Concepts
- Selenium - IE Driver
- Selenium - Automation Frameworks
- Selenium - Keyword Driven Framework
- Selenium - Data Driven Framework
- Selenium - Hybrid Driven Framework
- Selenium - SSL Certificate Error
- Selenium - Alternatives
Selenium - JUnit Report
Junit can be used to create a detailed automation test report. It is an open source framework which can be integrated with Selenium tests and used for reporting purposes.
Prerequisites to Create JUnit Report
- Install Java (version above 8) in the system from the link Java Downloads. To get more details setting up of Java, please refer to the link Java Environment Setup.
- Install maven in the system from the link Apache Maven. To get more details about setting up of Maven, refer to the link Maven Environment Setup
- Install IntelliJ from the link IntelliJ IDEA Ultimate. To get more details about setting up of IntelliJ, refer to the link Selenium IntelliJ.
Steps to Create JUnit Report
Step 1 − Create a maven project and add the proper dependencies to the pom.xml file for the below items −
- Add the Selenium Java dependencies from the link Selenium Java.
- Add the JUnit dependencies from the link JUnit.
- Add the JUnit Jupiter dependencies from the link JUnit Jupiter API.
- Add the Maven site dependencies from the link Apache Maven Site Plugin.
- Add the Maven Surefire Report dependencies from the link Maven Surefire Report Plugin.
- Save the pom.xml with all the dependencies and update the maven project.
Step 2 − Create a JUnit test class with the implementation of the below example where we will first click on the New User button verify the text Welcome, Login In on the Welcome Page.

On clicking the New User button, we will be navigating to the Registration page, having the Back to Login button as highlighted in the below image.

Code Implementation
package Report; import org.junit.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.TestMethodOrder; import java.util.concurrent.TimeUnit; import static org.junit.Assert.assertEquals; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class JunitTest { WebDriver driver; @Before public void setup() throws Exception{ // Initiate browser driver driver = new ChromeDriver(); // adding implicit wait of 20 secs driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); // Opening the webpage driver.get("https://www.tutorialspoint.com/selenium/practice/login.php"); } @Test @Order(1) public void verifyLoginAndRegisterPage() { // identify header then get text WebElement header = driver.findElement (By.xpath("//*[@id='signInForm']/h1")); String text = header.getText(); // assertions to test case to check login page assertEquals("Welcome, Login In", text); // navigate to register page WebElement btn = driver.findElement (By.xpath("//*[@id='signInForm']/div[3]/a")); btn.click(); // assertions added to test case to check register page WebElement btnchk = driver.findElement (By.xpath("//*[@id='signupForm']/div[5]/a")); boolean displayed = btnchk.isDisplayed(); // assertions to test case assertEquals(true, displayed); } @After public void teardown() { // quitting browser driver.quit(); } }
Dependencies in pom.xml file.
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>SeleniumJava</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>16</maven.compiler.source> <maven.compiler.target>16</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.11.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.10.2</version> </dependency> <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-site-plugin --> <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>4.0.0-M13</version> </dependency> </dependencies> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-report-plugin --> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>3.2.5</version> </plugin> </plugins> </reporting> </project>
Step 3 − Run the test from the command line with the command: mvn clean test suite.
Step 4 − Refresh the project and a new folder called the site should get generated within the target folder.

Step 5 − Right-click on the surefire-report.html and select the option to open in a browser.

The JUnit report will be opened in the browser showing the Summary with total number of test methods as 1, with a pass success percentage of 100. It also showed details of the Package List(name of the package, number of tests, passed counts, failed counts, pass success percentage, duration of tests and so on. Also, the test method name verifyLoginAndRegisterPage is also included in the report.
Conclusion
This concludes our comprehensive take on the tutorial on Selenium JUnit Report. Weve started with describing a JUnit report, prerequisites to set up an JUnit report, and walked through steps to create a JUnit report with an example illustrating how to use it along with Selenium. This equips you with in-depth knowledge of the JUnit. It is wise to keep practicing what youve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.