Skip to content

About

Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

63 Commits

Folders and files

Repository files navigation

AdvancedAutomationFramework

A Java-based UI test automation framework built with Selenium WebDriver, TestNG, and Maven, implementing the Page Object Model (POM) design pattern for maintainable end-to-end web testing.

Key Features

  • Page Object Model (POM): Clean separation between page interactions (pageobjects), shared UI components (AbstractComponents), and test suites (tests).
  • Centralized, Secret-Safe Configuration: ConfigReader loads GlobalData.properties, optional config-<env>.properties overlays (-Denv=qa|staging|prod), -D system properties, and UPPER_SNAKE_CASE environment variable overrides, with ${KEY} placeholder resolution in DataReader.
  • Thread-Safe Parallel Execution: BaseTest manages WebDriver instances via ThreadLocal<WebDriver> with driver.quit() cleanup, paired with ThreadLocal<ExtentTest> in Listeners.
  • Flakiness Analytics & Auto-Quarantine: FlakinessTracker persists per-test run counts, retries, failures, and durations to reports/flakiness-history.json, surfaces top flaky tests in ExtentReports, and auto-quarantines chronic offenders.
  • Data-Driven Testing: JSON test data parsing via Jackson (DataReader + PurchaseOrder.json) integrated with TestNG @DataProvider.
  • TestNG Suite & Listener Architecture: Supports grouped execution (Purchase, ErrorHandling), automatic retry (Retry implementing IRetryAnalyzer), and automatic failure screenshots.
  • Rich Reporting & Logging: Generates HTML reports via ExtentReports (reports/index.html) and structured logs via Log4j2 (logs/automation.log).
  • Containerized Execution: Dockerfile based on maven:3.9-eclipse-temurin-21 with google-chrome-stable for headless CI runs via Selenium Manager.

Tech Stack

Component Technology / Version
Language Java 21
Build Tool Apache Maven
Browser Automation Selenium WebDriver 4.54.0 (with Selenium Manager)
Test Runner TestNG 7.12.0
Reporting ExtentReports 5.1.2
JSON Parsing Jackson Databind 2.23.0
File Utilities Apache Commons IO 2.22.0
Logging Apache Log4j2 2.26.1

Project Structure

AdvancedAutomationFramework/
├── pom.xml                                  # Maven dependencies and build configuration
├── Dockerfile                               # Maven JDK 21 + headless Chrome container
├── AGENTS.md                                # Repository guide for AI coding agents
├── reports/                                 # Generated ExtentReports HTML & failure screenshots
├── testSuites/
│   ├── testng.xml                           # Full regression suite (SubmitOrder + ErrorValidations)
│   ├── Purchase.xml                         # Purchase group suite
│   └── ErrorValidationTests.xml             # ErrorHandling group suite
└── src/
    ├── main/java/org/miteshdandade/
    │   ├── AbstractComponents/
    │   │   └── AbstractComponent.java       # Base page class (configurable waits, navigation)
    │   ├── pageobjects/
    │   │   ├── LandingPage.java             # Login & landing page
    │   │   ├── ProductCatalogue.java        # Product listing & add-to-cart actions
    │   │   ├── CartPage.java                # Cart verification & checkout navigation
    │   │   ├── CheckoutPage.java            # Text-matched country selection & order submission
    │   │   ├── ConfirmationPage.java        # Order confirmation message
    │   │   ├── OrderPage.java               # Order history verification
    │   │   └── ProductNotFoundException.java# Domain exception for missing catalogue items
    │   └── resources/
    │       ├── ConfigReader.java            # Centralized properties/env/system-prop loader
    │       ├── ExtentReporterNG.java        # ExtentReports configuration
    │       └── GlobalData.properties        # Default browser, URL, and timeout settings
    └── test/
        ├── java/org/miteshdandade/
        │   ├── TestComponents/
        │   │   ├── BaseTest.java            # ThreadLocal WebDriver lifecycle, JSON data, screenshots
        │   │   ├── FlakinessTracker.java    # Persistent flakiness metrics & auto-quarantine
        │   │   ├── Listeners.java           # TestNG listener for ExtentReports, quarantine & screenshots
        │   │   └── Retry.java               # Configurable flaky test retry analyzer
        │   ├── data/
        │   │   ├── DataReader.java          # Jackson JSON-to-Map reader
        │   │   └── PurchaseOrder.json       # Sample test data
        │   ├── resources/
        │   │   └── ExtentReporterNGTest.java
        │   └── tests/
        │       ├── SubmitOrderTest.java     # End-to-end order & order history tests
        │       ├── ErrorValidationsTest.java# Negative login & product validation tests
        │       └── StandAloneTest.java      # Standalone reference script
        └── resources/
            └── log4j2.xml                   # Log4j2 appenders (Console + logs/automation.log)

Getting Started

Prerequisites

  • JDK 21 installed and configured on PATH (JAVA_HOME set).
  • Apache Maven 3.8+ installed and configured on PATH.
  • Google Chrome (default browser in GlobalData.properties; drivers are managed automatically by Selenium Manager).

Configuration

Defaults live in src/main/java/org/miteshdandade/resources/GlobalData.properties (env, browser, headless, baseUrl, explicitWaitSeconds, reportName, reportDocumentTitle, reportTester, maxRetryCount, quarantineEnabled, quarantineMinRuns, quarantineFailureRateThreshold). Override values via:

  • Optional environment file: config-<env>.properties (selected via -Denv=staging or ENV=staging)
  • Maven system properties: -Dbrowser=chromeheadless, -DbaseUrl=https://..., -Dheadless=true
  • Environment variables: BROWSER, HEADLESS, BASE_URL, EXPLICIT_WAIT_SECONDS, REPORT_TESTER, QUARANTINE_ENABLED
  • Test Credentials: PurchaseOrder.json and test classes resolve credentials via ConfigReader / ${ENV_VAR} placeholders. Provide TEST_USER_EMAIL, TEST_USER_PASSWORD, SECONDARY_USER_EMAIL, and SECONDARY_USER_PASSWORD (via env vars or -D properties) before running tests.

Running Tests

Run the default Maven test lifecycle:

mvn test

Run a specific TestNG suite:

mvn test -Dsurefire.suiteXmlFiles=testSuites/testng.xml
mvn test -Dsurefire.suiteXmlFiles=testSuites/Purchase.xml
mvn test -Dsurefire.suiteXmlFiles=testSuites/ErrorValidationTests.xml

Override the target browser via system property:

mvn test -Dbrowser=chromeheadless

Run in Docker:

docker build -t advanced-automation-framework .
docker run --rm advanced-automation-framework

Viewing Reports & Logs

  • HTML Test Report: reports/index.html
  • Flakiness History: reports/flakiness-history.json
  • Failure Screenshots: reports/<testMethodName>.png
  • Execution Logs: logs/automation.log

About

Ready-to-use UI Test Automation Architecture using Java and Selenium WebDriver.

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages