# nikeshdevkota/cross-browser-testing-pytest architecture

> Architecture diagram of the GitHub repository nikeshdevkota/cross-browser-testing-pytest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nikeshdevkota/cross-browser-testing-pytest
- Repository: https://github.com/nikeshdevkota/cross-browser-testing-pytest

## Overview

##### Project type and purpose
- This is a Selenium-based cross-browser test automation framework written in Python, using Pytest and the Page Object Model (POM).
- Its sole purpose is to automate end-to-end user flows (login, add to cart, checkout) against the Swag Labs demo site and generate HTML reports.

##### File structure
- Top-level files:
- conftest.py – defines shared fixtures (e.g. WebDriver setup, .env loader)
- requirements.txt – Python dependencies (selenium, pytest, pytest-xdist, pytest-html, python-dotenv)
- test_buy_items_and_checkout.py – a Pytest test case leveraging page objects
- Directories:
- pages/ – Page Object classes (login_page.py, inventory_page.py, cart_page.py, checkout_page.py)
- locators/ – Centralized locator definitions for each page (login_locators.py, etc.)

##### README for additional insights
- Requires a .env file to supply credentials and environment settings via python-dotenv in conftest.py.
- Tests run in parallel using pytest-xdist (`-n auto`) and produce a self-contained HTML report via pytest-html.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration Layer
    subgraph "Configuration Layer"
        LoadEnv[".env & python-dotenv"]:::config
        Conftest["conftest.py"]:::config
        README["README.md"]:::config
    end

    %% Test Orchestration Layer
    subgraph "Test Orchestration Layer"
        Runner["Pytest Runner + xdist + pytest-html"]:::orchestration
    end

    %% Test Code Layer
    subgraph "Test Code Layer"
        TestScript["test_buy_items_and_checkout.py"]:::test
    end

    %% Page Object & Locator Layer
    subgraph "Page Object & Locator Layer"
        subgraph "Page Objects"
            LoginPage["LoginPage"]:::page
            InventoryPage["InventoryPage"]:::page
            CartPage["CartPage"]:::page
            CheckoutPage["CheckoutPage"]:::page
        end
        subgraph "Locators"
            LoginLoc["LoginLocators"]:::locator
            InventoryLoc["InventoryLocators"]:::locator
            CartLoc["CartLocators"]:::locator
            CheckoutLoc["CheckoutLocators"]:::locator
        end
    end

    %% Driver Layer
    subgraph "Driver Layer"
        WebDriver["Selenium WebDriver"]:::driver
    end

    %% External System
    External["Swag Labs Application"]:::external

    %% Reporting Layer
    Reporting["HTML Report"]:::report

    %% Connections
    LoadEnv --> Conftest
    README --> Runner
    Conftest --> Runner
    Runner -->|"spawns ×N"| TestScript
    Runner --> Reporting
    TestScript --> LoginPage
    TestScript --> InventoryPage
    TestScript --> CartPage
    TestScript --> CheckoutPage
    LoginPage --> LoginLoc
    InventoryPage --> InventoryLoc
    CartPage --> CartLoc
    CheckoutPage --> CheckoutLoc
    LoginPage --> WebDriver
    InventoryPage --> WebDriver
    CartPage --> WebDriver
    CheckoutPage --> WebDriver
    WebDriver --> External

    %% Click Events
    click Conftest "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/conftest.py"
    click Runner "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/requirements.txt"
    click TestScript "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/test_buy_items_and_checkout.py"
    click LoginPage "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/pages/login_page.py"
    click InventoryPage "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/pages/inventory_page.py"
    click CartPage "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/pages/cart_page.py"
    click CheckoutPage "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/pages/checkout_page.py"
    click LoginLoc "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/locators/login_locators.py"
    click InventoryLoc "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/locators/inventory_locators.py"
    click CartLoc "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/locators/cart_locators.py"
    click CheckoutLoc "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/locators/checkout_locators.py"
    click README "https://github.com/nikeshdevkota/cross-browser-testing-pytest/blob/main/README.md"

    %% Styles
    classDef config fill:#9fd,stroke:#333;
    classDef orchestration fill:#f9d,stroke:#333;
    classDef test fill:#ddf,stroke:#333;
    classDef page fill:#bbf,stroke:#333;
    classDef locator fill:#bfb,stroke:#333;
    classDef driver fill:#fdb,stroke:#333;
    classDef external fill:#ccc,stroke:#666,stroke-dasharray: 5 5;
    classDef report fill:#dcb,stroke:#333;
```
