Skip to content

3bb/WebFramework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Testing Framework

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.

📋 Tech Stack

  • 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

🏗️ Key Architecture Features

1. Resilience & Synchronization (FluentWait)

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

2. Multi-Environment Routing

The framework uses a custom Project abstraction to handle different environments (Dev, Staging, Production) seamlessly.

  • Logic: Classes like SwagLabs extend GenericProject and define specific URLs/configurations based on the EnvironmentType enum.
  • Usage: You can switch the target environment globally using the environment parameter, and the framework automatically routes to the correct base URL.

3. Automatic Retry Mechanism

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.

4. Logging & Reporting

  • Log4j2: Used for detailed execution logs (Info, Warn, Error).
  • ExtentReports: Generates rich HTML reports including step-by-step logs of the execution.

⚙️ Configuration Parameters

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.

Default Browser Settings (Chrome)

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.

🚀 Installation & Usage

Prerequisites

  • Java JDK 11
  • Maven
  • Lombok Plugin for your IDE (e.g., Eclipse, IntelliJ) to handle Lombok annotations.

1. Build the Project

Install dependencies and build the project skipping tests:

mvn clean install -DskipTests

2. Execute Tests

Execute tests using Maven. You can override default configurations using -D flags.

Standard Run (Local, Chrome, Dev):

mvn clean test

We 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.xml

Specify a different browser (e.g., Edge but not implemented yet):

mvn clean test -Dbrowser=edge

3. View Reports

After 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

📁 Project Structure

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)```

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages