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.

On this page
  1. Problem and purpose
  2. Architecture
  3. Technology and tools
  4. Engineering decisions and approach
  5. Test scope and execution approach
  6. Results with dated evidence
  7. Evidence explorer
  8. Local setup and execution
  9. Workflow and reports
  10. Known limitations

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 variables

Technology and tools

AreaTools
LanguagePython 3.12
Test runnerpytest 9 (fixtures, markers, parametrize, hooks)
Browser automationPlaywright for Python 1.63 with pytest-playwright (Chromium, Firefox, WebKit)
APIrequests 2.34 (one Session per client)
Contractspydantic 2 models with extra fields forbidden
Parallel runs and reportpytest-xdist, pytest-html (one self-contained file), Playwright traces and videos
Code quality and CIruff (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.

Test report screenshot. pytest-html report of a full run: 46 passed. Static image; capture date is not recorded in the portfolio data.
pytest-html report: 46 tests passed

Test report screenshot. pytest-html report of a full run: 46 passed. Static image; capture date is not recorded in the portfolio data.

Test report screenshot. The report demo: a UI failure with its screenshot, an API failure with the API's message, a strict xfail and a skip. Static image; capture date is not recorded in the portfolio data.
pytest-html report of the demo run with failures, a skip and an xfail

Test report screenshot. The report demo: a UI failure with its screenshot, an API failure with the API's message, a strict xfail and a skip. Static image; capture date is not recorded in the portfolio data.

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 xfailed

Workflow and reports

View workflow definition.

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.

Back to Projects