# kkb18/playwright-automation-framework architecture

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

- Interactive diagram: https://gitdiagram.com/kkb18/playwright-automation-framework
- Repository: https://github.com/kkb18/playwright-automation-framework

## Overview

##### Main Components
- Automation Test Runner & Framework Configuration: This includes the configuration files—cucumber.js, playwright.config.ts, package.json, and tsconfig.json.
- Feature Files: Located in src/test/feature, these rich text files written in Gherkin syntax specify the test scenarios.
- Step Definitions: Found in src/test/steps, these files implement the test steps as defined in the feature files.
- Page Objects: In src/test/pages (and also in src/test/pactumJS/pages), these files encapsulate interactions with UI components.
- Helper Modules:
- Hooks (src/test/helper/hooks): Set up and tear down routines to be executed before/after test scenarios.
- Browser Management (src/test/helper/browser): Contains modules to deal with browser setup, context, and page lifecycle.
- Environment Variables (src/test/helper/env): Stores different environment configurations (.env files) and TypeScript definitions.
- Report & Logger (src/test/helper/report and src/test/helper/logger): Manages test execution reports and logging mechanisms.
- Test Data & Parameters (src/test/helper/testData and src/test/helper/parameters): Supplies user and system data; dynamic variable resolution.
- Attachments: For storing any attachments like documents, images, or PDFs relevant to test steps.
- Optional Components:
- PactumJS integration (under src/test/pactumJS): Contains pages, steps, and scripts (e.g., sasTokem.ps1) that might be used for API testing or extended UI testing scenarios.

##### Relationships and Interactions
- The Test Runner will coordinate running the feature files through Cucumber, using the configurations defined in cucumber.js.
- Feature Files (BDD specifications) drive execution by linking to relevant Step Definitions.
- Step Definitions leverage the Page Objects to perform actions on the web UI via Playwright.
- Helper modules such as hooks, browser management, and environment configurations are called during test setup and execution to manage browser sessions, configure environments, and capture logs/reports.
- CI/CD integration (as evident from GitHub Actions workflows in .github/workflows) ensures that tests are automatically run, with results published into the test-results folder.
- Report generation and logging are handled internally by dedicated modules to provide traceability and evidence of tests run.

##### Architectural Patterns & Key Design Principles
- Separation of Concerns: The framework cleanly divides BDD specifications, step implementations, page interactions, and utility functionalities.
- Modular Design: Helper modules (for browser, environment, logging, etc.) are organized in separate directories, making the framework extensible and maintainable.
- Reusability: The Page Object Model and step definition structure encourage reusing test logic across multiple feature files.
- CI/CD and Parallel Execution: The configuration and reporting modules support integration with CI/CD pipelines, emphasizing robustness and scalability.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Test Runner & Framework Configuration
    subgraph "Test Runner & Config"
        T1["cucumber.js"]:::config
        T2["playwright.config.ts"]:::config
        T3["package.json"]:::config
        T4["tsconfig.json"]:::config
    end

    %% Feature Files
    subgraph "Feature Files"
        F0["Feature Files Directory"]:::featureDir
        F1["LetCode.feature"]:::feature
        F2["OrangeHrmLogin.feature"]:::feature
        F3["PracticeExpandTesting.feature"]:::feature
    end

    %% Step Definitions
    subgraph "Step Definitions"
        S0["Steps Directory"]:::stepsDir
        S1["commonActionsOrangeHrm.step.ts"]:::step
        S2["commonAssertsOrangeHrm.step.ts"]:::step
        S3["expandTesting.step.ts"]:::step
        S4["letCode.step.ts"]:::step
    end

    %% Page Objects
    subgraph "Page Objects"
        subgraph "Primary Page Objects"
            P0["Primary Page Objects Directory"]:::pagesDir
            P1["expandTesting.page.ts"]:::page
            P2["letCode.page.ts"]:::page
            P3["orangeHrmElements.ts"]:::page
            P4["pageNavigation.ts"]:::page
        end
        subgraph "PactumJS Page Objects"
            PP1["pactumJs.page.ts"]:::page
        end
    end

    %% Helper Modules
    subgraph "Helper Modules"
        H1["Hooks"]:::helper
        H2["Browser Management"]:::helper
        H3["Environment Variables"]:::helper
        H4["Report"]:::helper
        H5["Logger"]:::helper
        H6["Test Data"]:::helper
        H7["Parameters"]:::helper
        H8["Attachments"]:::helper
    end

    %% Optional PactumJS Integration
    subgraph "Optional PactumJS Integration"
        PAX["PactumJS Integration"]:::optional
    end

    %% CI/CD Integration
    subgraph "CI/CD Integration"
        CD["GitHub Actions Pipeline"]:::cicd
    end

    %% Containment relationships within groups
    F0 --> F1
    F0 --> F2
    F0 --> F3

    S0 --> S1
    S0 --> S2
    S0 --> S3
    S0 --> S4

    P0 --> P1
    P0 --> P2
    P0 --> P3
    P0 --> P4

    %% Main flow connections
    T1 -->|"load_features"| F0
    F0 -->|"parse_features"| S0
    S0 -->|"invoke_steps"| P0

    %% Helper module interactions
    S0 -->|"run_hooks"| H1
    S0 -->|"fetch_testdata"| H6
    S0 -->|"resolve_parameters"| H7
    P0 -->|"ui_interaction"| H2
    H2 -->|"configure_browser"| H3
    S0 -->|"report"| H4
    H4 -->|"log_results"| H5
    H5 -->|"ci_integration"| CD

    %% Optional integration path
    PAX -->|"optional_API_test"| S0

    %% CI/CD trigger feedback
    CD -->|"trigger_tests"| T1

    %% Styling
    classDef config fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef featureDir fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef feature fill:#e6ffcc,stroke:#333,stroke-width:2px;
    classDef stepsDir fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef step fill:#d9ecff,stroke:#333,stroke-width:2px;
    classDef pagesDir fill:#ffe6cc,stroke:#333,stroke-width:2px;
    classDef page fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef helper fill:#d9d9d9,stroke:#333,stroke-width:2px;
    classDef optional fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d1ffd6,stroke:#333,stroke-width:2px;

    %% Click Events for Test Runner & Config
    click T1 "https://github.com/kkb18/playwright-automation-framework/blob/master/cucumber.js"
    click T2 "https://github.com/kkb18/playwright-automation-framework/blob/master/playwright.config.ts"
    click T3 "https://github.com/kkb18/playwright-automation-framework/blob/master/package.json"
    click T4 "https://github.com/kkb18/playwright-automation-framework/blob/master/tsconfig.json"

    %% Click Events for Feature Files
    click F0 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/feature"
    click F1 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/feature/LetCode.feature"
    click F2 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/feature/OrangeHrmLogin.feature"
    click F3 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/feature/PracticeExpandTesting.feature"

    %% Click Events for Step Definitions
    click S0 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/steps"
    click S1 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/steps/commonActionsOrangeHrm.step.ts"
    click S2 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/steps/commonAssertsOrangeHrm.step.ts"
    click S3 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/steps/expandTesting.step.ts"
    click S4 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/steps/letCode.step.ts"

    %% Click Events for Primary Page Objects
    click P0 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/pages"
    click P1 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/pages/expandTesting.page.ts"
    click P2 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/pages/letCode.page.ts"
    click P3 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/pages/orangeHrmElements.ts"
    click P4 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/pages/pageNavigation.ts"

    %% Click Events for PactumJS Page Objects
    click PP1 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/pactumJS/pages/pactumJs.page.ts"

    %% Click Events for Helper Modules
    click H1 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/helper/hooks/hooks.ts"
    click H2 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/helper/browser"
    click H3 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/helper/env"
    click H4 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/helper/report"
    click H5 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/helper/logger/logger.ts"
    click H6 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/helper/testData"
    click H7 "https://github.com/kkb18/playwright-automation-framework/blob/master/src/test/helper/parameters/resolveVariable.ts"
    click H8 "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/helper/attachments"

    %% Click Event for Optional PactumJS Integration
    click PAX "https://github.com/kkb18/playwright-automation-framework/tree/master/src/test/pactumJS"
```
