# anhtester/playwrightjava architecture

> Architecture diagram of the GitHub repository anhtester/playwrightjava, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anhtester/playwrightjava
- Repository: https://github.com/anhtester/playwrightjava

## Overview

##### Main Components
- Test Runner & Framework: At the heart of the project is the TestNG framework (used for executing test suites) which drives the test cases found under the “src/test” directory. This includes test classes, listeners (like AllureListener and TestListener), and suite XML configurations.
- Page Object Model (POM): Under “src/test/java/com/anhtester/pom/”, page classes (e.g., BasePage, and other page implementations for admin and user scenarios) are implemented using the POM design pattern. This abstraction clearly separates the UI interactions from the test logic.
- Browser and Test Managers: The “src/main/java/com/anhtester/managers” directory indicates dedicated managers like BrowserFactory (for browser session management) and PageManager (for handling page objects).
- Helper and Utility Modules: The project contains various helper classes (e.g., CaptureHelper, ExcelHelper, FileHelper, PropertiesHelper, and SystemHelper) under “src/main/java/com/anhtester/helpers” and utilities like LogUtils. These facilitate various cross-cutting concerns such as file operations, properties configuration, and logging.
- Reporting & Logging: Reporting is managed via classes like AllureManager, ExtentReportManager, and ExtentTestManager within “src/main/java/com/anhtester/reports”. Also, note that a log4j2.properties file in “src/main/resources” establishes the logging configuration.
- Configuration and Data Resources: The “src/test/resources” directory holds configuration files (config.properties) along with test data (like data.json) and suite configurations (Suite XML files). There is also a Maven pom.xml at the top-level for dependency management and build configuration.

##### Relationships and Interactions
- Helper & Utility Integration: The Test cases and page objects leverage helper modules for common functions (capturing screenshots, managing Excel data, file operations, etc.). Show these as supportive components linked with general utilities.

##### Important Architectural Patterns and Design Principles
- Page Object Model (POM): Emphasize how the project abstracts web page functionalities behind dedicated Page classes.
- Layered Architecture: Distinguish between test cases, page objects, managers, helpers, and reporting. Each layer has a distinct responsibility which minimizes coupling.
- Modular and Extensible Design: The use of dedicated helper classes and managers implies that each component can be maintained or extended independently.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Test Execution Layer
    subgraph "Test Execution Layer"
        TT["TestNG Tests"]:::test
        SC["Suite Configurations"]:::test
        TL["Test Listeners"]:::test
        BT["Base Test Class"]:::test
    end

    %% Page Object Model (POM)
    subgraph "Page Object Model (POM)"
        POM["Page Objects"]:::pom
    end

    %% Managers
    subgraph "Managers"
        BF["Browser Manager"]:::manager
        PM["Page Manager"]:::manager
    end

    %% Helpers & Utilities
    subgraph "Helpers & Utilities"
        HELP["Helper Modules"]:::helper
        LU["Logging Utility"]:::helper
    end

    %% Reporting & Logging
    subgraph "Reporting & Logging"
        RM["Reporting Managers"]:::report
        LC["Logging Config"]:::report
    end

    %% Configuration & Data Resources
    subgraph "Configuration & Data Resources"
        CF["Configuration File"]:::config
        TD["Test Data"]:::config
    end

    %% Build & Dependency
    subgraph "Build & Dependency"
        Maven["Maven Build (pom.xml)"]:::build
    end

    %% Relationships and Data Flow
    TT -->|"executes"| BT
    TT -->|"navigatesThrough"| POM
    TT -->|"triggers"| TL
    TT -->|"usesHelpers"| HELP
    TT -->|"logsEvent"| LU

    BT -->|"initializes"| BF
    BT -->|"managesPages"| PM

    POM <-->|"interactsWith"| BF

    TL -->|"sendsReportsTo"| RM

    LC -.->|"configures"| LU
    CF -->|"loadsConfig"| HELP

    SC -->|"definesSuitesFor"| TD

    Maven -->|"builds"| TT
    Maven --> BF
    Maven --> PM
    Maven --> HELP
    Maven --> RM

    %% Styles
    classDef test fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef pom fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef manager fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef helper fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef report fill:#D1C4E9,stroke:#512DA8,stroke-width:2px;
    classDef config fill:#FFECB3,stroke:#FF6F00,stroke-width:2px;
    classDef build fill:#B2DFDB,stroke:#00695C,stroke-width:2px;

    %% Click Events
    click TT "https://github.com/anhtester/playwrightjava/tree/main/src/test/java/com/anhtester/pom/testcases"
    click SC "https://github.com/anhtester/playwrightjava/tree/main/src/test/resources/suites"
    click TL "https://github.com/anhtester/playwrightjava/tree/main/src/test/java/com/anhtester/listeners"
    click BT "https://github.com/anhtester/playwrightjava/blob/main/src/test/java/com/anhtester/common/BaseTest.java"
    click POM "https://github.com/anhtester/playwrightjava/tree/main/src/test/java/com/anhtester/pom/pages"
    click BF "https://github.com/anhtester/playwrightjava/blob/main/src/main/java/com/anhtester/managers/BrowserFactory.java"
    click PM "https://github.com/anhtester/playwrightjava/blob/main/src/main/java/com/anhtester/managers/PageManager.java"
    click HELP "https://github.com/anhtester/playwrightjava/tree/main/src/main/java/com/anhtester/helpers"
    click LU "https://github.com/anhtester/playwrightjava/blob/main/src/main/java/com/anhtester/utils/LogUtils.java"
    click RM "https://github.com/anhtester/playwrightjava/tree/main/src/main/java/com/anhtester/reports"
    click LC "https://github.com/anhtester/playwrightjava/blob/main/src/main/resources/log4j2.properties"
    click CF "https://github.com/anhtester/playwrightjava/blob/main/src/test/resources/config/config.properties"
    click TD "https://github.com/anhtester/playwrightjava/blob/main/src/test/resources/data.json"
    click Maven "https://github.com/anhtester/playwrightjava/blob/main/pom.xml"
```
