# amirya412/pytest-playwright-automation architecture

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

- Interactive diagram: https://gitdiagram.com/amirya412/pytest-playwright-automation
- Repository: https://github.com/amirya412/pytest-playwright-automation

## Overview

This is a pytest/Playwright UI automation framework for SauceDemo. The principal workflow is a test run selecting an environment and browser, resolving page objects, then exercising login or inventory behavior against the site. Supporting layers provide environment-specific credentials, reusable UI components, cookie-based authentication, logging, and failure diagnostics. The README also describes screenshots, video, and HTML reports; source excerpts show trace-summary support and its pytest integration, but not the full artifact-generation path. Test modules and some fixture details were not sampled, so those links are limited to documented behavior.

Main entry points: [`factories/pages.py`](https://github.com/amirya412/pytest-playwright-automation/blob/main/factories/pages.py) (Page factory), [`conftest.py`](https://github.com/amirya412/pytest-playwright-automation/blob/main/conftest.py) (Pytest fixtures), [`support/environment.py`](https://github.com/amirya412/pytest-playwright-automation/blob/main/support/environment.py) (Environment config), [`pages/inventory_page.py`](https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/inventory_page.py) (Inventory page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_execution["Test execution"]
  node_test_login["Login tests<br/>[test_login.py]"]
  node_test_inventory["Inventory tests<br/>[test_inventory.py]"]
  node_fixtures["Pytest fixtures<br/>[conftest.py]"]
  node_factory["Page factory<br/>[pages.py]"]
end

subgraph group_pages["Page interaction"]
  node_login["Login page<br/>[login_page.py]"]
  node_inventory["Inventory page<br/>[inventory_page.py]"]
  node_base["Base page<br/>[base_page.py]"]
  node_header["Header component<br/>[header.py]"]
  node_sidebar["Sidebar menu<br/>[sidebar_menu.py]"]
end

subgraph group_config["Environment and auth"]
  node_environment["Environment config<br/>[environment.py]"]
  node_users["User credentials<br/>[users.py]"]
  node_auth["Cookie auth<br/>[auth_helper.py]"]
end

subgraph group_diagnostics["Logs and reports"]
  node_logger["Logger<br/>[logger.py]"]
  node_trace["Trace summary<br/>[trace_report.py]"]
  node_artifacts["Test artifacts"]
end

node_runner(("pytest runner"))
node_site["SauceDemo"]

node_runner -->|"starts tests"| node_fixtures
node_fixtures -->|"creates pages"| node_factory
node_fixtures -->|"configures"| node_environment
node_fixtures -->|"imports"| node_logger
node_fixtures -->|"uses"| node_trace
node_factory -->|"creates"| node_auth
node_factory -->|"creates"| node_login
node_factory -->|"creates"| node_inventory
node_factory -->|"uses"| node_environment
node_login -->|"extends"| node_base
node_inventory -->|"extends"| node_base
node_inventory -->|"creates"| node_header
node_inventory -->|"creates"| node_sidebar
node_base -->|"uses URL"| node_environment
node_environment -->|"loads credentials"| node_users
node_auth -->|"reads settings"| node_environment
node_test_login -.->|"uses pages"| node_factory
node_test_inventory -.->|"uses pages"| node_factory
node_test_login -.->|"tests UI"| node_site
node_test_inventory -.->|"tests UI"| node_site
node_trace -.->|"summarizes traces"| node_artifacts
node_runner -.->|"generates reports"| node_artifacts

click node_test_login "https://github.com/amirya412/pytest-playwright-automation/blob/main/tests/test_login.py"
click node_test_inventory "https://github.com/amirya412/pytest-playwright-automation/blob/main/tests/test_inventory.py"
click node_fixtures "https://github.com/amirya412/pytest-playwright-automation/blob/main/conftest.py"
click node_factory "https://github.com/amirya412/pytest-playwright-automation/blob/main/factories/pages.py"
click node_login "https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/login_page.py"
click node_inventory "https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/inventory_page.py"
click node_base "https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/base_page.py"
click node_header "https://github.com/amirya412/pytest-playwright-automation/blob/main/components/header.py"
click node_sidebar "https://github.com/amirya412/pytest-playwright-automation/blob/main/components/sidebar_menu.py"
click node_environment "https://github.com/amirya412/pytest-playwright-automation/blob/main/support/environment.py"
click node_users "https://github.com/amirya412/pytest-playwright-automation/blob/main/users/users.py"
click node_auth "https://github.com/amirya412/pytest-playwright-automation/blob/main/utilities/auth_helper.py"
click node_logger "https://github.com/amirya412/pytest-playwright-automation/blob/main/logger.py"
click node_trace "https://github.com/amirya412/pytest-playwright-automation/blob/main/support/trace_report.py"
click node_artifacts "https://github.com/amirya412/pytest-playwright-automation/tree/main/reports"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_test_login,node_test_inventory,node_fixtures,node_factory toneBlue
class node_login,node_inventory,node_base,node_header,node_sidebar toneAmber
class node_environment,node_users,node_auth toneMint
class node_logger,node_trace,node_artifacts toneRose
class node_runner,node_site toneIndigo
```

## Components

### Test execution

- [Login tests](https://github.com/amirya412/pytest-playwright-automation/blob/main/tests/test_login.py): `tests/test_login.py`
- [Inventory tests](https://github.com/amirya412/pytest-playwright-automation/blob/main/tests/test_inventory.py): `tests/test_inventory.py`
- [Pytest fixtures](https://github.com/amirya412/pytest-playwright-automation/blob/main/conftest.py): `conftest.py`
- [Page factory](https://github.com/amirya412/pytest-playwright-automation/blob/main/factories/pages.py): `factories/pages.py`

### Page interaction

- [Login page](https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/login_page.py): `pages/login_page.py`
- [Inventory page](https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/inventory_page.py): `pages/inventory_page.py`
- [Base page](https://github.com/amirya412/pytest-playwright-automation/blob/main/pages/base_page.py): `pages/base_page.py`
- [Header component](https://github.com/amirya412/pytest-playwright-automation/blob/main/components/header.py): `components/header.py`
- [Sidebar menu](https://github.com/amirya412/pytest-playwright-automation/blob/main/components/sidebar_menu.py): `components/sidebar_menu.py`

### Environment and auth

- [Environment config](https://github.com/amirya412/pytest-playwright-automation/blob/main/support/environment.py): `support/environment.py`
- [User credentials](https://github.com/amirya412/pytest-playwright-automation/blob/main/users/users.py): `users/users.py`
- [Cookie auth](https://github.com/amirya412/pytest-playwright-automation/blob/main/utilities/auth_helper.py): `utilities/auth_helper.py`

### Logs and reports

- [Logger](https://github.com/amirya412/pytest-playwright-automation/blob/main/logger.py): `logger.py`
- [Trace summary](https://github.com/amirya412/pytest-playwright-automation/blob/main/support/trace_report.py): `support/trace_report.py`
- [Test artifacts](https://github.com/amirya412/pytest-playwright-automation/tree/main/reports): `reports`

### Other components

- **pytest runner**
- **SauceDemo**

## Connections

- pytest runner → Pytest fixtures: starts tests (evidence: `README.md`)
- Pytest fixtures → Page factory: creates pages (evidence: `conftest.py`)
- Pytest fixtures → Environment config: configures (evidence: `conftest.py`)
- Pytest fixtures → Logger: imports (evidence: `conftest.py`)
- Pytest fixtures → Trace summary: uses (evidence: `conftest.py`)
- Page factory → Cookie auth: creates (evidence: `factories/pages.py`)
- Page factory → Login page: creates (evidence: `factories/pages.py`)
- Page factory → Inventory page: creates (evidence: `factories/pages.py`)
- Page factory → Environment config: uses (evidence: `factories/pages.py`)
- Login page → Base page: extends (evidence: `pages/login_page.py`)
- Inventory page → Base page: extends (evidence: `pages/inventory_page.py`)
- Inventory page → Header component: creates (evidence: `pages/inventory_page.py`)
- Inventory page → Sidebar menu: creates (evidence: `pages/inventory_page.py`)
- Base page → Environment config: uses URL (evidence: `pages/base_page.py`)
- Environment config → User credentials: loads credentials (evidence: `support/environment.py`)
- Cookie auth → Environment config: reads settings (evidence: `utilities/auth_helper.py`)
- Login tests → Page factory: uses pages
- Inventory tests → Page factory: uses pages
- Login tests → SauceDemo: tests UI
- Inventory tests → SauceDemo: tests UI
- Trace summary → Test artifacts: summarizes traces
- pytest runner → Test artifacts: generates reports (evidence: `README.md`)
