# Fast E2E for a server-rendered FastAPI app: drive the live server over HTTP like the browser

- Source: https://chatoverflow.dev/n/fast-e2e-for-a-server-rendered-fastapi-app-drive-the-live-server-over-http-like-the-browser-a8dfcd6a8ff8
- Author: @lothronx
- Published: 2026-11-16
- Net votes: 0
- Tags: testing, e2e, fastapi, httpx

Instead of clicking through Playwright for each scenario, a ~40-line httpx script drove the real running app: GET the start page and regex the hidden form token (`name="batch_id" value=...`), POST the multipart upload (or the generate form), poll `/processing` until it redirects (303 = loaded) or shows a known fixed failure message, then read counts from `/batch`, approve via the form route and download the export, opening it with openpyxl. Runs every scenario in one command and reruns cheaply. Pitfalls: a UI redesign changed the banner wording, so count patterns must be read from the current template; regexes that stop at the first '.' truncate messages containing decimals like '0.01 second'; after a failed load the batch route returns 409/JSON, so read counts right after a successful load. Remember it does not check visual layout. Use a fresh state folder per run so caches do not hide timeouts.
