This is an industry-standard, data-driven test automation framework built with Selenium WebDriver, Java, TestNG, and Maven. The framework follows enterprise-level best practices including Page Object Model (POM), data-driven testing, comprehensive logging, and detailed reporting.
- Page Object Model (POM) - Separation of test logic and page elements
- Singleton Pattern - DriverManager and Report Manager
- Factory Pattern - Configuration management
- Data-Driven Testing - External JSON test data
β
Selenium 4.16.1 - Latest WebDriver features
β
TestNG 7.9.0 - Parallel execution support
β
Log4j2 - Industry-standard logging
β
ExtentReports - Rich HTML reports with screenshots
β
WebDriverManager - Automatic browser driver management
β
Jackson - JSON data parsing
β
Owner - External configuration management
β
AssertJ - Fluent, readable assertions
selenium-java-framework/
βββ src/main/java/com/demoapp/
β βββ base/ # Base classes
β βββ pages/ # Page Object classes
β βββ utils/ # Utility classes
β βββ constants/ # Framework constants
β βββ enums/ # Type-safe enumerations
β βββ config/ # Configuration management
βββ src/test/java/com/demoapp/
β βββ tests/ # Test classes
β βββ listeners/ # TestNG listeners
βββ src/test/resources/
β βββ testdata/ # JSON test data
βββ logs/ # Execution logs
βββ screenshots/ # Failed test screenshots
βββ test-output/reports/ # ExtentReports HTML
- Java JDK 11 or higher
- Maven 3.6+
- IntelliJ IDEA / Eclipse IDE
- Chrome/Firefox browser
-
Clone or create the project
mkdir selenium-java-framework cd selenium-java-framework -
Add pom.xml to project root
-
Create folder structure as shown above
-
Add configuration files:
- log4j2.xml (root directory)
- config.properties (src/main/resources/)
- .gitignore (root directory)
-
Install dependencies
mvn clean install
# Run all tests
mvn clean test
# Run specific test
mvn test -Dtest=DemoAppTest
# Run with custom browser
mvn test -Dbrowser=chrome
# Run in headless mode
mvn test -Dheadless=truemvn test -DsuiteXmlFile=testng.xml- Right-click on
DemoAppTest.javaβ Run as TestNG Test
- Location:
test-output/reports/ExtentReport.html - Features: Screenshots, test duration, pass/fail status
- Open in any browser for interactive report
- Location:
test-output/index.html - Default TestNG HTML report
- Location:
logs/automation.log - Rotating file appender (10MB size, 10 backups)
Edit config.properties to customize:
# Application
app.url=https://your-app-url.com
# Browser (chrome, firefox, edge)
browser=chrome
headless=false
# Timeouts
explicit.wait=20
page.load.timeout=30
# Test Data
login.email=admin
login.password=password123Test data is stored in testData.json:
{
"loginCredentials": {
"email": "admin",
"password": "password123"
},
"testCases": [
{
"testId": "TC001",
"project": "Web Application",
"task": "Implement user authentication",
"column": "To Do",
"tags": ["Feature", "High Priority"]
}
]
}- ThreadLocal WebDriver for parallel execution
- Automatic browser initialization
- Graceful driver cleanup
- Common WebDriver operations
- Explicit wait strategies
- Element interaction methods
- LoginPage - Login functionality
- ProjectPage - Project and task verification
- Read test data from JSON
- POJO mapping with Jackson
- Type-safe data access
- Test execution reporting
- Screenshot capture on failure
- Test step logging
- ITestListener implementation
- Automatic screenshot on failure
- Test result logging
- β Separation of Concerns - Tests, pages, utilities separated
- β DRY Principle - Reusable components
- β Explicit Waits - No Thread.sleep()
- β Parameterization - External test data
- β Logging - Comprehensive Log4j2 logging
- β Reporting - Professional ExtentReports
- β Version Control - .gitignore configured
- β Constants - No hardcoded values
- β Type Safety - Enums for browser types
- β Clean Code - Meaningful names, proper indentation
This framework is Jenkins-ready:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean compile'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
}
post {
always {
publishHTML([
reportDir: 'test-output/reports',
reportFiles: 'ExtentReport.html',
reportName: 'Test Report'
])
}
}
}- Create class in
pages/package - Extend
BasePage - Define locators as
Byobjects - Implement action methods
- Create class in
tests/package - Extend
BaseTest - Use
@Testannotation - Add test data to JSON
- Create class in
utils/package - Follow Singleton pattern if needed
- Add logging statements
Podsho Boshkhuja
SDET | Selenium | Java | TestNG
Location: Ashburn, VA
This is a practice framework for learning and portfolio purposes.
Note: This framework follows industry standards observed at companies like GEICO, Freedom Bank, and follows patterns recommended by Selenium, TestNG, and Java communities.