A sample end-to-end UI automation project using Java, Selenium WebDriver, Spring Boot, and JUnit 5. Implements Page Object Model (POM) structure and demonstrates best practices for UI test automation, including screenshot capture on test failure.
- Overview
- Prerequisites
- Installation & Setup
- Running Tests
- Screenshot on Failure
- Project Structure
- Custom Assertions
- Contributing
- License
This repository demonstrates browser automation using Selenium WebDriver with Spring Boot integration. Automated UI tests leverage JUnit 5 and Allure for reporting, with features such as:
- Page Object Model (POM) for maintainable test code
- Dependency injection for test objects
- Automatic screenshots on assertion/operation failure for debugging
- Java 17+
- Maven
- Chrome or Firefox browser (web drivers configured via Spring Boot configuration)
- Internet access for dependency resolution
Clone this repository:
git clone https://github.com/YOUR_REPO_URL/selenium-java
cd selenium-javaInstall project dependencies:
mvn clean installConfigure application properties (credentials, URLs) in src/main/resources/application.properties:
app.login.username=your-username
app.login.password=your-password
app.baseUrl=<WebSite URL>
To execute all UI tests:
mvn testAllure report can be generated after the tests:
mvn allure:serveWhenever an assertion or element operation fails, a screenshot will be captured automatically and stored in the screenshots/ directory at the project root. Screenshots are named by test and operation.
src/
main/
java/
com.master.selenium/
config/ # Spring Boot WebDriver config
core/ # BasePage, core utilities
pages/ # Page Object Model classes
reporting/ # Reporting utilities (if any)
utils/ # ScreenshotUtils and other helpers
resources/
application.properties
test/
java/
com.master.selenium.tests/ # Test classes (JUnit 5)
com.master.selenium.utils/ # Test-specific utilities (AssertUtils)
com.master.selenium.core/ # BaseTest
screenshots/ # Captured screenshots on failure
Assertion helper methods in AssertUtils provide auto-screenshot functionality for test failures and should be used instead of direct JUnit assertions for maximum visibility.
Feel free to fork this repository and submit pull requests. Suggestions and improvements welcome.
This project is licensed under the MIT License.