How viplove29/python-ui-api-automation-framework works
1. This repository is a Python test automation framework with two independent test surfaces: browser UI tests and HTTP API tests. It is organized around Pytest as the test runner, with Selenium for UI and Requests-style client code for API coverage.
2. The top-level execution flow starts in tests/, where tests are split into tests/ui and tests/api. pytest.ini likely defines shared pytest behavior such as discovery rules, markers, and runtime settings, while tests/conftest.py supplies fixtures that wire tests to the framework objects.
3. The UI automation stack is layered. core/driver_factory.py is the browser bootstrap boundary: it creates the WebDriver based on configuration and supports local cross-browser runs. core/selenium_wrapper.py sits above raw Selenium and centralizes common actions such as click, type, waits, and element interaction.
4. Page Object Model is implemented under pages/. pages/base_page.py is the shared abstraction that page classes build on, and pages/saucedemo_login_page.py is a concrete page object for the SauceDemo login flow. Tests should interact with page methods rather than low-level locators, which keeps business intent separate from UI mechanics.
5. The API side is isolated under api/. api/api_client.py acts as the reusable HTTP client boundary for non-UI tests, so API test cases can call a small client API instead of managing request plumbing directly.
6. Configuration is centralized in config/config.yaml. This is the main runtime control point for things like browser selection and other environment-specific settings, which means the same test code can run locally in different browser modes or in CI without code changes.
7. The framework is designed to run in parallel with Pytest-xdist, as noted in the README and supported by the test layout. That makes the test runner an orchestration layer over independent UI/API tests rather than a single serialized workflow.
8. External test targets are demo systems rather than internal application services. The UI test names and page object indicate SauceDemo as the browser target, and the API example in the README points to a demo endpoint pattern such as httpbin. This suggests the repo is a framework template, not an app-under-test itself.
9. CI is handled by GitHub Actions in .github/workflows/ci.yml. The pipeline runs on push and uses a Docker Selenium Chrome environment, which means browser execution in CI is containerized and standardized rather than dependent on a developer workstation.
10. Docker support is provided separately in docker/Dockerfile. That container image is intended to package the test runtime and dependencies so the same framework can be executed consistently in local containers or CI jobs.
11. Dependencies are declared in requirements.txt, so the repository’s runtime footprint is entirely Python-based. The stack is intentionally lightweight: Pytest for orchestration, Selenium for UI, Requests for API, and supporting libraries for parallelization/reporting.
12. Reporting is Allure-ready, but reporting itself is not a core runtime dependency of the framework. It is an output concern layered on top of test execution, which keeps test code independent from report generation.
13. Overall, the key architectural boundaries are: test orchestration in tests/, browser control in core/, page abstractions in pages/, API client logic in api/, and execution/environment control in config/, Docker, and GitHub Actions. A diagram should show Pytest as the entry point, branching into UI and API paths, with configuration feeding both, and CI/Docker as the execution infrastructure around them.
Main entry points: pytest.ini Pytest · ci.yml CI workflow · conftest.py Fixtures · test_saucedemo_login.py UI tests
Components 16
Testing
Pytest-based execution and test surfaces
- Pytest · Discovers and orchestrates UI and API tests
pytest.ini - Fixtures · Shared test fixtures wiring framework objects into tests
tests/conftest.py - UI tests · Browser-based end-to-end coverage
tests/ui/test_saucedemo_login.py - API tests · HTTP-level coverage against demo endpoints
tests/api/test_demo_api.py
UI automation
Browser automation stack and page objects
- Driver factory · Creates WebDriver instances from configuration
core/driver_factory.py - Selenium wrapper · Centralizes common browser actions and waits
core/selenium_wrapper.py - Base page · Shared page-object foundation for UI flows
pages/base_page.py - Login page · SauceDemo login flow page object
pages/saucedemo_login_page.py
API automation
HTTP client boundary and API tests
- API client · Reusable request boundary for API coverage
api/api_client.py
Runtime
Configuration, container, and CI execution
- Config · Central settings for browser and environment behavior
config/config.yaml - Docker image · Packages the test runtime for consistent execution
docker/Dockerfile - CI workflow · GitHub Actions pipeline for containerized test runs
.github/workflows/ci.yml - Dependencies · Python package set for test execution
requirements.txt
Other components
- SauceDemo · Demo browser application under test
- Demo API · Demo HTTP endpoint used by API tests
- Allure · Reporting layer generated from test execution
Connections 19
- Pytest → Fixtures: loads · Pytest initializes shared fixtures and hooks
- Pytest → UI tests: runs · Discovers and executes UI tests
- Pytest → API tests: runs · Discovers and executes API tests
- Fixtures → Driver factory: provides · Fixtures create and manage browser sessions
- Fixtures → API client: provides · Fixtures expose reusable API clients
- UI tests → Login page: uses · UI tests call page-object methods
- Login page → Base page: extends · Concrete page inherits shared page behavior
- Base page → Selenium wrapper: delegates · Page abstractions use the shared Selenium wrapper
- Selenium wrapper → Driver factory: uses · Wrapper operates on created WebDriver instances
- Driver factory → Config: reads · Browser selection and runtime settings come from config
- UI tests → SauceDemo: targets · Browser tests exercise the SauceDemo demo app
- API tests → API client: uses · API tests call the shared HTTP client
- API client → Demo API: targets · Client issues requests to the demo API endpoint
- Config → CI workflow: drives · Same settings support local and CI execution modes
- Docker image → CI workflow: supports · Container image is used for standardized execution
- Dependencies → Pytest: installs · Dependency set enables test execution
- Pytest → Allure: emits · Test runs can produce Allure reporting artifacts
- CI workflow → Pytest: invokes · CI runs the test suite on push
- CI workflow → Docker image: builds · Pipeline uses containerized test runtime