# jaydipmaniya/ui-automation-selenium-python-pytest architecture

> Architecture diagram of the GitHub repository jaydipmaniya/ui-automation-selenium-python-pytest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jaydipmaniya/ui-automation-selenium-python-pytest
- Repository: https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest

## Overview

##### Project Type and Purpose
- This repository is a UI test automation framework written in Python using Selenium WebDriver and Pytest.
- It implements the Page Object Model (POM) design pattern, organizes locators, test data, and utility libraries, and generates logs/reports.

##### File Structure Analysis
- Top-level:
- README.md – framework description & usage
- requirements.txt – Python dependencies
- conftest.py – pytest fixtures (e.g. WebDriver setup/teardown)
- tests/ – test suite (one end-to-end test)
- utils/ (the core framework code)
- data/ – test data (LOGIN_EMAIL, LOGIN_PASSWORD)
- locators/ – Page Object locators for elements
- pages/ – Page classes encapsulating UI interactions
- lib/ – utility modules (LoggerUtils, WebDriver management)

##### README Insights
- Uses WebDriver Manager to auto-install browser drivers
- Default browser: Chrome; optional Firefox via CLI flag
- Generates timestamped log files and an optional HTML report

##### Main Components
a. Test Runner & Entry Point
- pytest CLI → conftest.py fixtures → tests/test_amazon_login_search_add_product_to_cart.py
b. Page Object Layer
- BasePage.py (common methods: click, send_keys, wait)
- AmazonAddProductToCart.py (high-level user flows)
c. Locator Layer
- amazon_add_product_to_cart.py (By-locators keyed to page elements)
d. Test Data Layer
- amazon_add_product_to_cart_data.py (constants for credentials, search terms)
e. Utility Layer
- LoggerUtils.py (configures and writes log files)
- WebDriver setup (in conftest.py using WebDriverManager)
f. External Systems
- Browser (Chrome or Firefox)
- Amazon website (System Under Test)
g. Output Artifacts
- log-<timestamp>.log
- pytest HTML report

##### Relationships & Data Flow
1. pytest CLI invocation loads conftest fixtures → Instantiates WebDriver
2. Test case calls Page Object methods
3. Page Objects use Locator definitions + Data inputs → Selenium WebDriver API calls
4. Browser executes actions against Amazon UI
5. Responses/status captured, returned to test
6. Utilities log each step and capture screenshots on failure
7. After test suite completes, pytest generates HTML report

##### Architectural Patterns & Design Principles
- Page Object Model (separation of UI structure from test logic)
- Layered framework: Tests → Pages → Locators/Data → Utils
- Dependency inversion: tests depend on abstractions (Page classes), not raw Selenium calls
- Reusability: common logging and driver management extracted to utils/lib

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Tests Layer
    subgraph "Tests Layer"
        pytestCLI["pytest CLI"]:::tests
        Conftest["conftest.py"]:::tests
        TestScript["test_amazon_login_search_add_product_to_cart.py"]:::tests
    end

    %% Page Object Layer
    subgraph "Page Object Layer"
        BasePage["BasePage.py"]:::pages
        AddProductPage["AmazonAddProductToCart.py"]:::pages
    end

    %% Locator and Data Layer
    subgraph "Locator & Data Layer"
        LocatorModule["amazon_add_product_to_cart.py"]:::locdata
        DataModule["amazon_add_product_to_cart_data.py"]:::locdata
    end

    %% Utility Layer
    subgraph "Utility Layer"
        LoggerUtils["LoggerUtils.py"]:::utils
        WDManager["WebDriverManager"]:::utils
    end

    %% Selenium & External Systems
    subgraph "Execution Layer"
        WebDriver["Selenium WebDriver"]:::external
        Browser["Browser (Chrome/Firefox)"]:::external
        AmazonUI["Amazon UI (SUT)"]:::external
    end

    %% Output Artifacts
    subgraph "Output Artifacts"
        LogFile["log-<timestamp>.log"]:::output
        HTMLReport["pytest HTML Report"]:::output
    end

    %% Connections
    pytestCLI -->|"loads fixtures"| Conftest
    Conftest -->|"sets up"| WebDriver
    Conftest -->|"uses"| WDManager
    pytestCLI -->|"runs"| TestScript
    TestScript -->|"invokes methods on"| BasePage
    TestScript -->|"invokes methods on"| AddProductPage
    AddProductPage -->|"inherits from"| BasePage
    AddProductPage -->|"uses locators"| LocatorModule
    AddProductPage -->|"uses data"| DataModule
    AddProductPage -->|"calls Selenium API on"| WebDriver
    LocatorModule -->|"provides By-locators"| WebDriver
    DataModule -->|"provides test data"| AddProductPage
    WebDriver -->|"drives actions in"| Browser
    Browser -->|"renders and interacts with"| AmazonUI
    AddProductPage -->|"logs steps via"| LoggerUtils
    Conftest -->|"logs driver events via"| LoggerUtils
    LoggerUtils -->|"writes logs to"| LogFile
    pytestCLI -->|"generates"| HTMLReport

    %% Click Events
    click Conftest "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/conftest.py"
    click TestScript "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/tests/test_amazon_login_search_add_product_to_cart.py"
    click BasePage "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/utils/pages/BasePage.py"
    click AddProductPage "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/utils/pages/AmazonAddProductToCart.py"
    click LocatorModule "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/utils/locators/amazon_add_product_to_cart.py"
    click DataModule "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/utils/data/amazon_add_product_to_cart_data.py"
    click LoggerUtils "https://github.com/jaydipmaniya/ui-automation-selenium-python-pytest/blob/main/utils/lib/LoggerUtils.py"

    %% Styles
    classDef tests fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef pages fill:#d4edda,stroke:#333,stroke-width:1px
    classDef locdata fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef utils fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef output fill:#d1ecf1,stroke:#333,stroke-width:1px
```
