# sadiqmalik8/hybridframework architecture

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

- Interactive diagram: https://gitdiagram.com/sadiqmalik8/hybridframework
- Repository: https://github.com/sadiqmalik8/hybridframework

## Overview

##### Project type and purpose
- This is a Java-based Selenium test-automation framework using the Page Object Model (POM) pattern.
- It automates end-to-end tests against the SwagLabs.com web application.
- Key features: TestNG test runner, POM classes for pages, Excel-driven data (Apache POI), ExtentReports, Log4j logging.

##### File structure
- Top-level directory “SeleniumPOM” holds all code, drivers, configs, test output.
- src/main/java/SwagLabs:
- Base: BaseClass.java (initializes WebDriver, loads config)
- Config: config.properties (URL, credentials, timeouts)
- Pages: one class per page (LoginPage, HomePage, CartPage, CheckoutPage)
- Utility: WebEventListener, UtilityClass (common helper methods), ExtentReporter
- TestData: Excel file for data-driven tests
- src/main/resources: Log4j config, TestNG suite XMLs
- src/test/java/SwagLabs/TestCases: TestNG test classes invoking POM methods
- chromedriver.exe & geckodriver.exe for WebDriver bindings
- test-output & target: generated reports, logs, compiled classes

##### README
- Confirms POM design, Apache POI, Extent Report, Log4j
- Indicates the AUT is SwagLabs.com

a. Main components
1. Test Runner Layer: TestNG suites (testng.xml/testng_sanity.xml)
2. Configuration Layer: config.properties, Log4j
3. Base Framework Layer: BaseClass (WebDriver init), WebEventListener
4. Page Object Layer: LoginPage, HomePage, CartPage, CheckoutPage
5. Test Data Layer: Excel sheet (Apache POI)
6. Utility & Reporting Layer: UtilityClass, ExtentReporter
7. External/Infrastructure: ChromeDriver/GeckoDriver, Browser, SwagLabs web app
8. Output Layer: TestNG reports, ExtentReports, logs in test-output folder

b. Relationships and data flow
- BaseClass reads config.properties → initializes WebDriver & listeners
- Test Cases call methods on Page Object classes → page objects use WebDriver to drive the browser
- Page Objects fetch test data from Excel via UtilityClass → data passed into page actions
- After each test, ExtentReporter & Log4j capture events → generate HTML/JS/CSS reports in test-output
- WebDriver interacts with AUT (SwagLabs.com) over HTTP

c. Architectural patterns & principles
- Page Object Model (separation of page locators and tests)
- Single Responsibility: each class has one role (config loader, driver manager, test case, reporter)
- Data-Driven Testing (Excel + Apache POI)
- Observer/Listener Pattern: WebEventListener intercepts WebDriver events

d. Technologies & frameworks
- Selenium WebDriver (browser automation)
- Java + TestNG (test framework)
- Apache POI (Excel reading)
- ExtentReports (rich HTML reporting)
- Log4j (logging)
- Maven (build & dependency management)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Execution Layer"
        direction TB
        TestNG_Suites["TestNG Suites"]:::yellow
        TestCases["Test Cases (TestNG)"]:::yellow
    end

    subgraph "Configuration Layer"
        direction TB
        ConfigProp["config.properties"]:::orange
        Log4jProp["log4j.properties"]:::orange
    end

    subgraph "Core Framework Layer"
        direction TB
        BaseClass["BaseClass"]:::blue
        WebListener["WebEventListener"]:::blue
    end

    subgraph "Page Object Layer"
        direction TB
        LoginPage["LoginPage"]:::green
        HomePage["HomePage"]:::green
        CartPage["CartPage"]:::green
        CheckoutPage["CheckoutPage"]:::green
    end

    subgraph "Test Data Layer"
        direction TB
        Excel["SwagLabsTestData.xlsx"]:::orange
    end

    subgraph "Utility & Reporting Layer"
        direction TB
        UtilityClass["UtilityClass"]:::blue
        ExtentReporter["ExtentReporter"]:::blue
    end

    subgraph "External Resources"
        direction TB
        ChromeDriver["chromedriver.exe"]:::gray
        GeckoDriver["geckodriver.exe"]:::gray
        AUT["SwagLabs.com"]:::gray
    end

    subgraph "Output Layer"
        direction TB
        TestNGReport["TestNG Reports"]:::purple
        ExtentHTML["ExtentReports HTML"]:::purple
        Logs["Log Files"]:::purple
    end

    TestNG_Suites -->|"runs"| TestCases
    TestCases -->|"startSession()"| BaseClass
    BaseClass -->|"reads config"| ConfigProp
    BaseClass -->|"registers listener"| WebListener
    TestCases -->|"invoke login"| LoginPage
    TestCases -->|"invoke home"| HomePage
    TestCases -->|"invoke cart"| CartPage
    TestCases -->|"invoke checkout"| CheckoutPage
    LoginPage -->|"uses WebDriver"| BaseClass
    HomePage -->|"uses WebDriver"| BaseClass
    CartPage -->|"uses WebDriver"| BaseClass
    CheckoutPage -->|"uses WebDriver"| BaseClass
    Excel -->|"reads data"| UtilityClass
    UtilityClass -->|"provides data"| LoginPage
    UtilityClass -->|"provides data"| HomePage
    UtilityClass -->|"provides data"| CartPage
    UtilityClass -->|"provides data"| CheckoutPage
    BaseClass -->|"launches driver"| ChromeDriver
    ChromeDriver -->|"instantiates browser"| BaseClass
    BaseClass -->|"navigates to AUT"| AUT
    WebListener -->|"captures events"| ExtentReporter
    WebListener -->|"logs events"| Logs
    ExtentReporter -->|"writes report"| ExtentHTML
    TestNG_Suites -->|"generates results"| TestNGReport
    Log4jProp -->|"configures logging"| Logs

    click TestNG_Suites "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/resources/testng.xml"
    click TestNG_Suites "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/resources/testng_sanity.xml"
    click ConfigProp "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Config/config.properties"
    click Log4jProp "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/resources/log4j.properties"
    click BaseClass "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Base/BaseClass.java"
    click WebListener "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Utility/WebEventListener.java"
    click LoginPage "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Pages/LoginPage.java"
    click HomePage "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Pages/HomePage.java"
    click CartPage "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Pages/CartPage.java"
    click CheckoutPage "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Pages/CheckoutPage.java"
    click Excel "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/TestData/SwagLabsTestData.xlsx"
    click UtilityClass "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Utility/UtilityClass.java"
    click ExtentReporter "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/src/main/java/SwagLabs/Utility/ExtentReporter.java"
    click ChromeDriver "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/chromedriver.exe"
    click GeckoDriver "https://github.com/sadiqmalik8/hybridframework/blob/master/SeleniumPOM/geckodriver.exe"
    click TestNGReport "https://github.com/sadiqmalik8/hybridframework/tree/master/SeleniumPOM/test-output/"
    click ExtentHTML "https://github.com/sadiqmalik8/hybridframework/tree/master/SeleniumPOM/test-output/"
    click Logs "https://github.com/sadiqmalik8/hybridframework/tree/master/SeleniumPOM/test-output/"

    classDef yellow fill:#FFEB3B,stroke:#333,stroke-width:1px
    classDef orange fill:#FFCC80,stroke:#333,stroke-width:1px
    classDef blue fill:#90CAF9,stroke:#333,stroke-width:1px
    classDef green fill:#A5D6A7,stroke:#333,stroke-width:1px
    classDef gray fill:#B0BEC5,stroke:#333,stroke-width:1px
    classDef purple fill:#CE93D8,stroke:#333,stroke-width:1px
```
