# eliasnogueira/selenium-java-lean-test-architecture architecture

> Architecture diagram of the GitHub repository eliasnogueira/selenium-java-lean-test-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eliasnogueira/selenium-java-lean-test-architecture
- Repository: https://github.com/eliasnogueira/selenium-java-lean-test-architecture

## Overview

##### Project Type and Purpose
- This project is a test automation framework built with Java and Selenium WebDriver. Its purpose is to provide a lean, extendable architecture for web tests that supports multiple execution platforms (local, Selenium Grid, TestContainers) and incorporates industry best practices (Page Object pattern, data factories, parallel execution, logging, reporting, etc.).
- The README clearly outlines the testing strategies and execution types, while the file tree reveals a multi-layered implementation (configuration, driver handling, page objects, data, etc.).

##### Analyzing the File Structure
- The src/main/java directory is organized in a typical layered manner with packages for config, driver, data, enums, exceptions, model, page, and report – each representing a different facet of the test automation framework.
- The presence of files like grid/docker-compose.yml, configuration properties files, and multiple CI/CD pipeline definitions (.github/workflows, .gitlab-ci.yml, Jenkinsfile) highlight that the project is designed for both local and distributed/parallel executions.

##### Key Components
a. Test Execution Layer:
- Base Test (BaseWeb class) and TestNG integration that control preconditions (browser creation via annotations) and postconditions (teardown).
- TestListener integration for logging, screenshot capture, and detailed reporting.
b. Driver & Execution Management:
- BrowserFactory: Handles local, remote, and TestContainers browser creation. Represent its methods (createLocalDriver, createDriver, getOptions, createTestContainerDriver) as key decision points.
- DriverManager: Manages WebDriver instances via ThreadLocal storage for parallel execution.
- TargetFactory: Decides the execution type based on configuration (local, selenium-grid, testcontainers) from the properties file.
c. Page Objects and UI Interaction:
- AbstractPageObject and NavigationPage (and other pages under the booking package) that encapsulate web elements and behaviours. Emphasize the Page Object pattern used for the test automation.
d. Data and Configuration:
- Configuration & ConfigurationManager classes for properties handling, separating general and grid-specific configurations.
- BookingDataFactory and the Builder (BookingBuilder) pattern for creating dynamic test data.
- Configuration files (general.properties, grid.properties, log4j2.properties) that abstract test environment and logging settings.
e. Reporting and Logging:
- Allure Report integration (AllureManager, AllureTestLifecycleListener) for test visualization and logging via Log4J2.

##### Relationships and Interactions
– BaseWeb → TargetFactory determines the execution type → BrowserFactory and/or DriverManager provision the WebDriver instance.
- How the test methods interact with Page Objects (derived from AbstractPageObject) and how these page interactions send commands to the WebDriver.
- Configuration flow: properties loaded via ConfigurationManager, which supplies settings (e.g., timeout, browser, grid.url) to various components.
- That after test execution, the TestListener captures logs and failures, interfacing with Allure for enriched test reports.
- If applicable, note Docker and CI/CD elements:
– Docker grid (grid/docker-compose.yml) and pipeline-as-code components (.github, .gitlab-ci.yml, Jenkinsfile) are used to coordinate parallel/distributed testing.

##### Detailed Elements
- Each component should have:
– Clear labels (e.g., “BaseWeb (Test Runner)”, “BrowserFactory (Driver Creation)”, “AbstractPageObject (UI Interaction)”).
▸ How test execution flows from BaseWeb to DriverManager and then to the page objects.
▸ How configuration settings are fed from ConfigurationManager to BrowserFactory, etc.
▸ Infrastructure/configuration components versus dynamic test execution components versus external integrations (like Docker or CI pipelines).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Test Execution & Listener
    subgraph "Test Execution & Listener"
        TW["BaseWeb (Test Runner)"]:::testStyle
        TL["TestListener (Reporting Listener)"]:::testStyle
    end

    %% Driver & Execution Management
    subgraph "Driver & Execution Management"
        TF["TargetFactory (Execution Decider)"]:::driverStyle
        BF["BrowserFactory (Driver Creation)"]:::driverStyle
        DM["DriverManager (WebDriver Manager)"]:::driverStyle
    end

    %% Page Objects & UI Interaction
    subgraph "Page Objects & UI Interaction"
        AOP["AbstractPageObject (UI Interaction)"]:::pageStyle
        NP["NavigationPage (UI Navigation)"]:::pageStyle
    end

    %% Data & Configuration
    subgraph "Data & Configuration"
        CM["ConfigurationManager (Properties Loader)"]:::configStyle
        BDF["BookingDataFactory (Test Data Builder)"]:::configStyle
        PF["Property Files (general, selenium-grid, log4j2)"]:::configStyle
    end

    %% Reporting & Logging
    subgraph "Reporting & Logging"
        AM["AllureManager (Test Reporting)"]:::reportStyle
    end

    %% CI/CD & Docker
    subgraph "CI/CD & Docker"
        DG["Selenium Grid (Docker Compose)"]:::cicdStyle
        GH["GitHub Actions (CI Pipeline)"]:::cicdStyle
        GL["GitLab CI (CI Pipeline)"]:::cicdStyle
        JF["Jenkins (CI Pipeline)"]:::cicdStyle
    end

    %% Interactions and Data Flow
    TW -->|"invokes"| TF
    TF -->|"selects execution for"| BF
    BF -->|"provides driver to"| DM
    TW -->|"executes tests using"| DM
    TW -->|"interacts with"| AOP
    AOP -->|"utilizes"| DM
    AOP -->|"navigates via"| NP
    PF -->|"loaded by"| CM
    CM -->|"supplies settings to"| BF
    CM -->|"supplies settings to"| TF
    TW -->|"acquires test data from"| BDF
    TL -->|"captures outcomes for"| TW
    TL -->|"integrates with"| AM

    %% CI/CD triggers and orchestration
    GH -->|"triggers"| TW
    GL -->|"triggers"| TW
    JF -->|"triggers"| TW
    DG -->|"orchestrates grid for"| BF

    %% Click Events
    click TW "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/test/java/com/eliasnogueira/BaseWeb.java"
    click TL "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/report/AllureTestLifecycleListener.java"
    click BF "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/driver/BrowserFactory.java"
    click DM "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/driver/DriverManager.java"
    click TF "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/driver/TargetFactory.java"
    click AOP "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/page/AbstractPageObject.java"
    click NP "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/page/booking/common/NavigationPage.java"
    click CM "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/config/ConfigurationManager.java"
    click BDF "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/data/dynamic/BookingDataFactory.java"
    click PF "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/test/resources/general.properties"
    click AM "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/src/main/java/com/eliasnogueira/report/AllureManager.java"
    click DG "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/grid/docker-compose.yml"
    click GH "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/tree/main/.github/workflows/"
    click GL "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/blob/main/.sdlc/.gitlab-ci.yml"
    click JF "https://github.com/eliasnogueira/selenium-java-lean-test-architecture/tree/main/.sdlc/Jenkinsfile"

    %% Styles
    classDef testStyle fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef driverStyle fill:#BBDEFB,stroke:#333,stroke-width:2px;
    classDef pageStyle fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef configStyle fill:#FFECB3,stroke:#333,stroke-width:2px;
    classDef reportStyle fill:#B2DFDB,stroke:#333,stroke-width:2px;
    classDef cicdStyle fill:#D1C4E9,stroke:#333,stroke-width:2px;
```
