Java Maven Selenium Framework (TestNG + Maven + POM)
📁 Project Structure Overview
This is a modular TestNG-based hybrid automation framework following Page Object Model (POM) structure with utilities, logging, listeners, and screenshot features.
🔸 1. src/main/java
– Core Framework
📦 base
- BaseTest.java: Common setup/teardown logic using WebDriver, @BeforeMethod, and @AfterMethod.
📦 factory
- DriverFactory.java: WebDriver creation logic, supports multiple browsers.
📦 listeners
- ReportListeners.java: Implements
ITestListener
, captures events like onTestSuccess, onTestFailure, etc.
📦 pages
- LoginPage.java, ProductsPage.java: Follows Page Object Model, encapsulates locators and actions.
📦 utilities
- ConfigReader.java: Reads data from
.properties
files. - ScreenshotUtil.java: Captures screenshots on failure.
- WaitUtil.java: Reusable WebDriverWait methods.
🔸 2. src/test/java
– Test Code
- LoginTest.java, LogoutTest.java: Contains actual
@Test
methods using page classes.
🔸 3. src/test/resources
– Configuration
- DEV-config.properties, QA-config.properties: Environment-specific configs (URL, credentials).
- log4j2.properties: Logging configuration file for Log4j2.
🔸 4. logs/automation.log
Log file generated during test execution.
🔸 5. screenshots/
Screenshots automatically captured on test failure. Example:
Screenshot_testLoginWithLockedCredentials_20072025_134120.png
🔸 6. testng.xml
TestNG suite file for organizing test execution. Example:
<suite name="Regression Suite">
<test name="Login Tests">
<classes>
<class name="tests.LoginTest"/>
</classes>
</test>
</suite>
🔸 7. pom.xml
Maven file used for dependency management (Selenium, TestNG, Log4j, etc.).
✅ Key Features
Feature | Description |
---|---|
Page Object Model (POM) | Improves modularity and maintainability |
TestNG | Powerful test execution framework |
Listeners | Captures test lifecycle events |
Screenshot Capture | Takes screenshots on test failure |
Log4j Logging | Logs test flow and issues |
Environment Config | Supports DEV/QA environments |
Maven | Manages dependencies and builds |
📝 Advantages
- Highly modular and reusable
- Screenshot and log-based debugging
- Easy to integrate with Jenkins or CI tools
- Supports parallel test execution via TestNG