Create a browser context with the recordHar option: browser.newContext({ recordHar: { path: 'fixture.har', urlFilter: '**/api/**' } }) to capture only the relevant API traffic
Navigate the page and perform the interactions whose network traffic you want to record; when done, call context.close() which finalizes and writes the HAR file to disk
In your test, use the routeFromHAR option when creating the context: browser.newContext({ routeFromHAR: { path: 'fixture.har', notFound: 'abort' } }) to replay recorded responses without hitting the network
Commit the HAR file to source control alongside the tests so CI runs are reproducible and do not depend on external API availability
To update the HAR after an API change, re-record by running the context with recordHar against the live API and replacing the committed fixture file
Known gotchas
HAR files can contain sensitive data including authorization headers and cookies captured during recording — scrub or redact credentials before committing to source control
The notFound option controls what happens when a request is not in the HAR: 'abort' fails the request (strict mode), 'fallback' allows live network calls — use 'abort' to catch missed recordings early
HAR replay matches requests by URL and method; if the API uses dynamic query parameters or request bodies for routing, the match may fail — use urlFilter to narrow the recorded scope to stable URL patterns
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp