Skip to content

podshobosh/selenium-DDT-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Selenium-Java Data-Driven Test Automation Framework

🎯 Overview

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.

πŸ—οΈ Framework Architecture

Design Patterns Used:

  • 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

Key Features:

βœ… 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

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites:

  • Java JDK 11 or higher
  • Maven 3.6+
  • IntelliJ IDEA / Eclipse IDE
  • Chrome/Firefox browser

Setup Instructions:

  1. Clone or create the project

    mkdir selenium-java-framework
    cd selenium-java-framework
  2. Add pom.xml to project root

  3. Create folder structure as shown above

  4. Add configuration files:

    • log4j2.xml (root directory)
    • config.properties (src/main/resources/)
    • .gitignore (root directory)
  5. Install dependencies

    mvn clean install

πŸ§ͺ Running Tests

Via Maven:

# 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=true

Via TestNG XML:

mvn test -DsuiteXmlFile=testng.xml

Via IDE:

  • Right-click on DemoAppTest.java β†’ Run as TestNG Test

πŸ“Š Reports

ExtentReports:

  • Location: test-output/reports/ExtentReport.html
  • Features: Screenshots, test duration, pass/fail status
  • Open in any browser for interactive report

TestNG Reports:

  • Location: test-output/index.html
  • Default TestNG HTML report

Logs:

  • Location: logs/automation.log
  • Rotating file appender (10MB size, 10 backups)

πŸ”§ Configuration

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=password123

πŸ“ Test Data Management

Test 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"]
    }
  ]
}

🎯 Framework Components

1. DriverManager

  • ThreadLocal WebDriver for parallel execution
  • Automatic browser initialization
  • Graceful driver cleanup

2. BasePage

  • Common WebDriver operations
  • Explicit wait strategies
  • Element interaction methods

3. Page Objects

  • LoginPage - Login functionality
  • ProjectPage - Project and task verification

4. JsonDataReader

  • Read test data from JSON
  • POJO mapping with Jackson
  • Type-safe data access

5. ExtentReportManager

  • Test execution reporting
  • Screenshot capture on failure
  • Test step logging

6. TestListener

  • ITestListener implementation
  • Automatic screenshot on failure
  • Test result logging

πŸ† Best Practices Implemented

  1. βœ… Separation of Concerns - Tests, pages, utilities separated
  2. βœ… DRY Principle - Reusable components
  3. βœ… Explicit Waits - No Thread.sleep()
  4. βœ… Parameterization - External test data
  5. βœ… Logging - Comprehensive Log4j2 logging
  6. βœ… Reporting - Professional ExtentReports
  7. βœ… Version Control - .gitignore configured
  8. βœ… Constants - No hardcoded values
  9. βœ… Type Safety - Enums for browser types
  10. βœ… Clean Code - Meaningful names, proper indentation

πŸ” CI/CD Integration

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'
            ])
        }
    }
}

πŸ“ˆ Extending the Framework

Add New Page:

  1. Create class in pages/ package
  2. Extend BasePage
  3. Define locators as By objects
  4. Implement action methods

Add New Test:

  1. Create class in tests/ package
  2. Extend BaseTest
  3. Use @Test annotation
  4. Add test data to JSON

Add New Utility:

  1. Create class in utils/ package
  2. Follow Singleton pattern if needed
  3. Add logging statements

πŸ‘¨β€πŸ’» Author

Podsho Boshkhuja
SDET | Selenium | Java | TestNG
Location: Ashburn, VA

πŸ“„ License

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.

About

Data-Driven Test Automation Framework using Selenium, Java, TestNG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published