[Feature]: Record and replay browser network as pure requests
Currently, when automating a site with the browser, reproducing the same flow in pure HTTP requires manually inspecting DevTools, copying requests, and rewriting them with requests. This is slow, error-prone, and makes it hard to migrate a working browser automation into a stable “requests-only” script.
We should introduce a recorder for tab.request that captures all network activity during a browser session and makes it reusable without the browser. The idea is to run code like:
async with tab.request.record() as rec:
# everything inside this block, like clicks,
# login, forms will be recorded
rec.save("flow.har")
await tab.request.replay("flow.har")
This would allow users to record a working browser-driven flow (login, navigation, API calls) and later replay it deterministically with no browser. Perfect for stable pipelines, CI, and porting browser automations into pure HTTP scripts.
Requirements:
- Capture method, URL, headers, cookies, body, status, redirects, and timing.
- Store recordings in HAR (with minimal extensions for cookies/metadata).
- Ignore static assets (images, fonts) by default, focusing on API and document requests.
- Provide an optional code exporter (flow.py) that generates equivalent Python using
requestslibrary.