Project | Web & API
Python pytest + Playwright Framework
A requests API client with pydantic contracts, Playwright page objects, login through the API by token injection, a throwaway user per test, and a screenshot in the HTML report for every failed UI test.
46 tests (32 API, 9 UI, 5 hybrid API + UI) in about 1 m 45 s with 4 parallel workers; in CI the UI and hybrid tests run on Chromium, Firefox and WebKit.
Evidence checked 19 Oct 2026 | CI workflow and README test matrix
On this page
Problem and purpose
Shows a Python test stack for one application with a web UI and a REST API on the same backend: the public Expand Testing Notes app. The API carries most of the checks, the browser checks what a user sees, and hybrid tests check that the two sides agree.
Architecture
tests/api, tests/ui, tests/e2e what is checked
│ fixtures (tests/conftest.py): throwaway user per test, logged-in client,
│ page with ads blocked, page already logged in, report hooks
│
framework/api NotesApiClient (requests) + pydantic models
framework/pages LoginPage, NotesPage (data-testid locators, no assertions), open_page
framework/data unique users and notes (uuid)
│
framework/retry with_retries: timeouts only, safe-to-repeat calls only
framework/config URLs, timeouts and attempts from environment variablesTechnology and tools
| Area | Tools |
|---|---|
| Language | Python 3.12 |
| Test runner | pytest 9 (fixtures, markers, parametrize, hooks) |
| Browser automation | Playwright for Python 1.63 with pytest-playwright (Chromium, Firefox, WebKit) |
| API | requests 2.34 (one Session per client) |
| Contracts | pydantic 2 models with extra fields forbidden |
| Parallel runs and report | pytest-xdist, pytest-html (one self-contained file), Playwright traces and videos |
| Code quality and CI | ruff (lint + format), GitHub Actions: lint gate, API job, browser matrix, nightly run |
Engineering decisions and approach
- Every test registers its own user through the API and deletes it in teardown, so tests are independent and safe with pytest-xdist on a shared public site
- UI tests log in by putting the API token into localStorage before the page loads; the login form itself is tested once
- The API client returns raw responses and never asserts, so the same client serves positive and negative tests
- pydantic models with extra="forbid": an added or renamed field fails a test at once instead of passing silently
- Page objects hold data-testid locators and actions; tests assert with Playwright's retrying expect, with no sleeps anywhere
- Demo tests that fail, skip and xfail on purpose carry their own marker and stay out of normal runs
- A slow public site is retried, not ignored: only timeouts, only calls that are safe to repeat (page loads, GET/PUT/PATCH/DELETE, login), a timed-out registration starts over with a new user, and assertions are never retried
Test scope and execution approach
Project-specific checks and execution details documented in the repository:
- 32 API tests: registration and validation, login, the same 401 for a wrong password and an unknown user, token checks, profile, password change, logout, notes CRUD with PUT and PATCH, bad ids, one user cannot see another user's notes
- 9 UI tests: login form, adding, completing, deleting and searching notes
- 5 hybrid tests: data created through the API shown in the app, changes made in the app checked through the API
- HTML report with an embedded screenshot for every failed UI test; Playwright screenshot, video and trace kept for failures
- Framework design notes and 86 interview questions with answers linked to the code (Markdown + PDF)
Results with dated evidence
Historical repository or workflow evidence · older evidence; recheck the linked source
CI workflow and README test matrix
46 tests (32 API, 9 UI, 5 hybrid API + UI) in about 1 m 45 s with 4 parallel workers; in CI the UI and hybrid tests run on Chromium, Firefox and WebKit.
Evidence checked: | Open dated evidence
Evidence explorer
Static screenshots are labelled as images; dated workflow links identify the execution evidence and its check date.
Static material from the public repository. The linked verification record was checked 2026-10-19; that date is not a screenshot capture date.
Dated workflow record
Evidence checked 2026-10-19. Open CI workflow and README test matrix
Local setup and execution
python -m venv .venv && .venv\Scripts\activate
pip install -r requirements.txt
playwright install chromium firefox webkit
pytest -n 4 # all 46 tests
pytest -m api # API only
pytest -m "ui or e2e" --browser firefox # browser tests on Firefox
pytest -m demo # report demo: 2 failed, 1 skipped, 1 xfailedWorkflow and reports
Known limitations
- Runs against a shared public demo site: page loads and server round trips get 30 s and timeouts are tried three times, but a longer outage still fails the run
- Visual and accessibility checks are not included yet
- The evidence is limited to the public repository and linked run; it does not establish customer production impact.