# argodevops/pybehave-selenium-test-framework architecture

> Architecture diagram of the GitHub repository argodevops/pybehave-selenium-test-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/argodevops/pybehave-selenium-test-framework
- Repository: https://github.com/argodevops/pybehave-selenium-test-framework

## Overview

##### Project Type & Purpose
- This is an open-source BDD-style test automation framework built on Python.
- It provides UI testing via Selenium WebDriver, API testing via Python requests, and data-driven support via Jinja templates.
- Key audiences: QA engineers writing feature tests and framework developers extending core behavior.

##### Main Architectural Layers
A. Test Suite Layer (User-facing)
– Gherkin feature files (`pybehave/features/*.feature`)
– Step definitions (`pybehave/features/steps/*_steps.py`)
– Environment setup (`features/environment.py`)

B. Framework Layer (Core platform)
– Facades (`support/facades/*`) – high-level test logic combining multiple actions
– Page Actions (`support/pageactions/*`) – Page Object Model implementations
– Core ElementAction (`support/core/elementaction.py`) – low-level Selenium calls with retry/back-off
– API Client Actions (`support/apiclientactions/apiclient.py`) – HTTP request wrappers
– Builders & Templates (`support/builders/*`) – Jinja2-based payload generation
– Locators (`support/locators/*`) – abstraction of element selectors
– Configuration & Utilities (`support/config.py`, `utils/*`) – settings reader, vault integration, logging

##### External Systems & Artifacts
– Web browsers (Chrome, Edge) driven by WebDriver binaries in `drivers/`
– Remote Selenium Grid (optional) via a Hub URL
– Target applications under test (UI endpoints, API endpoints, test databases)
– Reporting & Logging: Allure, behave JSON (`reports/`), screenshots (`screenshots/`)

##### Interactions & Data Flow
1. Behave CLI / Docker container starts → reads `test-settings.json` & default config
2. Behave runner kicks off each feature file → matches steps to Python step functions
3. Step functions call into Facade classes → orchestrate UI/API flows
4. Facades delegate to:
- Page Actions → ElementAction → WebDriver → Browser → Target UI
- API Client → HTTP Requests → Target API
- Database Actions → DB client → Test DB (if applicable)
- Builders → read template → produce test payloads
5. Core ElementAction handles retries, waits, screenshots on failure
6. All actions logged and emitted to Behave reporters → Allure/JSON + screenshots

##### Architectural Patterns & Principles
- Layered separation (Test Suite vs. Framework)
- Page Object Model (support/pageactions + locators)
- Facade pattern (high-level test flows)
- Retry/back-off strategy in core element actions
- Pluggable drivers (local binaries vs. Selenium Grid)
- Data-driven via templates and config readers

##### Extensibility Points to Highlight
– Adding new browser drivers (drop into `drivers/`)
– New page actions & locators for additional pages
– Additional ApiclientActions or Database actions
– Customizing config via `test-settings.json` or key vault

## Diagram (Mermaid)

```mermaid
graph TB
    %% Test Suite Layer
    subgraph "Test Suite Layer"
        F["Gherkin Feature Files"]:::testSuite
        S["Step Definitions"]:::testSuite
        E["Environment Setup"]:::testSuite
    end

    %% Framework Layer
    subgraph "Framework Layer"
        Fd["Facades"]:::framework
        PA["Page Actions"]:::framework
        CE["Core ElementAction"]:::framework
        API["API Client Actions"]:::framework
        BT["Builders & Templates"]:::framework
        L["Locators"]:::framework
        subgraph "Config & Utilities"
            CFG["Config Reader"]:::framework
            DCFG["Default Config"]:::framework
            TSF["Test Settings"]:::framework
            UTIL["Utilities"]:::framework
        end
    end

    %% External Systems
    subgraph "External Systems"
        WD["WebDriver Binaries"]:::external
        BR["Browser"]:::external
        SG["Selenium Grid"]:::external
        APIEND["API Endpoint"]:::external
        DB["Test Database"]:::external
        RPT["Reporting (Allure/JSON)"]:::external
        SCR["Screenshots"]:::external
    end

    %% Connections
    F -->|matches steps| S
    S -->|runs in env| E
    S -->|calls| Fd
    Fd -->|uses| PA
    PA -->|invokes| CE
    CE -->|drives| WD
    WD -->|launches| BR
    WD -.optional.-> SG
    Fd -->|calls| API
    API -->|HTTP requests| APIEND
    BT -->|provides payloads to| Fd
    BT -->|provides payloads to| API
    L -->|used by| PA
    CFG -->|configures| Fd
    CFG -->|configures| PA
    CFG -->|configures| CE
    CFG -->|configures| API
    CFG -->|configures| BT
    CFG -->|configures| L
    UTIL -->|helper functions for| Fd
    UTIL -->|helper functions for| PA
    UTIL -->|helper functions for| CE
    UTIL -->|helper functions for| API
    UTIL -->|helper functions for| BT
    UTIL -->|helper functions for| L
    CE -->|on failure captures| SCR
    CE -->|logs to| RPT

    %% Click Events
    click F "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/features/*.feature"
    click S "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/features/steps/*_steps.py"
    click E "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/features/environment.py"
    click Fd "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/support/facades/"
    click PA "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/support/pageactions/"
    click CE "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/support/core/elementaction.py"
    click API "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/support/apiclientactions/apiclient.py"
    click BT "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/support/builders/"
    click L "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/support/locators/"
    click CFG "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/support/config.py"
    click DCFG "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/configuration/default-config.json"
    click TSF "https://github.com/argodevops/pybehave-selenium-test-framework/blob/main/pybehave/support/test-settings.json"
    click UTIL "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/utils/"
    click WD "https://github.com/argodevops/pybehave-selenium-test-framework/tree/main/pybehave/drivers/"

    %% Styles
    classDef testSuite fill:#e0f7fa,stroke:#006064,color:#000
    classDef framework fill:#e8f5e9,stroke:#1b5e20,color:#000
    classDef external fill:#eeeeee,stroke:#424242,color:#000
```
