Production-Ready Selenium POM Framework (Java + TestNG + ExtentReports)
This article provides a ready-to-use, production-grade Selenium Page Object Model (POM) framework you can drop straight into a Java project.
The stack includes:
- Java 17 + Maven
- Selenium 4 + WebDriverManager
- TestNG (parallel-ready)
- ExtentReports 5 (Spark) with screenshots on failure
- Log4j2 logging
- Multi-environment config (dev / qa / prod)
- Centralized locator repository (
ElementRepository) - Thread-safe WebDriver and thread-safe Extent tests
You can copy this HTML into the Blogspot HTML editor and it will render nicely with a clean, pure white background.
1. Project Structure
Recommended Maven project layout:
You can change the base package com.automationcodes.automation if needed—just update package
declarations consistently.
2. Maven pom.xml
3. Environment & Configuration
3.1 Environment.java
3.2 ConfigManager.java
3.3 Sample config file
src/test/resources/config/config-dev.properties:
4. Core WebDriver Layer
4.1 DriverManager.java
4.2 DriverFactory.java
4.3 WaitUtils.java
4.4 TestContext.java
5. Utilities: Logging & Screenshots
5.1 LoggerUtil.java
5.2 ScreenshotUtil.java
5.3 log4j2.xml
6. Centralized Element Locators
ElementRepository groups locators by page.
7. Page Objects
7.1 BasePage.java
7.2 LoginPage.java
7.3 HomePage.java
8. ExtentReports Integration
8.1 ExtentManager.java
8.2 ExtentTestManager.java
9. TestNG Listener (Extent + Screenshots + Allure)
10. Base Test Class & Sample Tests
10.1 BaseTest.java
10.2 LoginTests.java
11. TestNG Suite
src/test/resources/testng.xml:
12. Running the Framework
From the project root:
Dev (default profile)
QA
Prod
Generated artifacts:
- Extent HTML report:
target/reports/ExtentReport_<timestamp>.html - Screenshots on failure:
target/screenshots - Logs:
target/logs/framework.log
0 Comments