A robust and scalable automated testing framework built using Java 11, Selenium WebDriver, and TestNG. This project utilizes the Page Object Model (POM) design pattern to separate testing logic from UI elements and includes features for advanced reporting and environment configuration management.
- Language: Java 11
- Core: Selenium WebDriver (v4.34.0)
- Test Runner: TestNG (v7.4.0)
- Reporting: ExtentReports (v4.1.6)
- Logging: Log4j2
- Data Parsing: OpenCSV
- Utilities: Lombok
To ensure test stability and handle dynamic web elements, the framework implements Fluent Wait within the base page class (GenericPage).
- Timeout: 30 seconds
- Polling: Every 1 second
- Exceptions Ignored:
NoSuchElementException,StaleElementReferenceException
The framework uses a custom Project abstraction to handle different environments (Dev, Staging, Production) seamlessly.
- Logic: Classes like
SwagLabsextendGenericProjectand define specific URLs/configurations based on theEnvironmentTypeenum. - Usage: You can switch the target environment globally using the
environmentparameter, and the framework automatically routes to the correct base URL.
To mitigate flaky tests, a custom RetryAnalyzer is integrated.
- Behavior: If a test fails, it is automatically retried up to 2 additional times (Max Retry Count = 2) before being marked as a final failure.
- Log4j2: Used for detailed execution logs (Info, Warn, Error).
- ExtentReports: Generates rich HTML reports including step-by-step logs of the execution.
The framework supports dynamic configuration via System Properties (passed with -D). The following parameters are available:
| Parameter | Description | Default / Options |
|---|---|---|
environment |
Target environment for execution. | Dev (default). Value is mapped to EnvironmentType enum. |
browser |
Browser used for testing. | chrome (default). Framework also has stubs for firefox and edge. |
executionType |
Execution mode (local machine or remote grid). | local (default), remote. |
retryMechanism |
Enables automatic retry for failed tests. | true or false (default: false). |
suiteName |
Custom name for the test suite (used in reports). | Any string. |
The default ChromeDriver is initialized with specific options for stability:
start-maximized--disable-notifications&--disable-infobars- Password manager popups and security alerts are automatically dismissed or disabled.
- Java JDK 11
- Maven
- Lombok Plugin for your IDE (e.g., Eclipse, IntelliJ) to handle Lombok annotations.
Install dependencies and build the project skipping tests:
mvn clean install -DskipTestsExecute tests using Maven. You can override default configurations using -D flags.
Standard Run (Local, Chrome, Dev):
mvn clean testWe recommend the following custom runs:
Custom Run Example (Local, Chrome, Staging with Retry):
mvn clean test -Denvironment=Staging -Dbrowser=chrom -DexecutionType=local -DretryMechanism=true -DsuiteName="Demo Suite Run"Specify a different TestNG XML suite file (e.g., for regression tests, assuming sauce-demo.xml exists):
mvn clean test -Dsurefire.suiteXmlFiles=src/main/resources/sauce-demo.xmlSpecify a different browser (e.g., Edge but not implemented yet):
mvn clean test -Dbrowser=edgeAfter test execution, detailed HTML reports are generated using ExtentReports. Open the report located at:
Artefacts/TestResults-Demo_Suite_Run-staging-2026-01-16_12-02.html
src
├── main
│ ├── java
│ │ └── testingFramework
│ │ ├── database # Database connection classes and POJOs
│ │ ├── frameworkFactory # Factories for WebDriver and Environment initialization
│ │ ├── pageObjects # Page Object Model (POM) classes representing UI pages
│ │ │ └── components # Reusable UI components (e.g., ListingItem)
│ │ ├── projects # Project-specific abstractions and configurations
│ │ ├── reporting # Reporting configuration (ExtentManager)
│ │ ├── Utils # Utility classes (Configuration, Logger, SoftAssert)
│ │ ├── RetryAnalyzer.java # Logic for automatically retrying failed tests
│ │ ├── TestFactory.java # Factory for dynamic test creation
│ │ └── TestNGListeners.java # TestNG listeners for logging and reporting
│ └── resources
│ ├── log4j2.xml # Log4j2 logging configuration
│ └── users.csv # Test data files
└── test
└── java
└── tests # Actual test suites (e.g., SauceDemoSuite)```