Listen for all requests in a test by attaching page.on('request', request => console.log(request.url(), request.method())) and page.on('response', response => ...) before triggering the action under test
For targeted collection, use page.waitForRequest(urlOrPredicate) and page.waitForResponse(urlOrPredicate) to await specific network calls and get their Request/Response objects
Access response bodies with await response.json() or await response.text() for programmatic assertions on API payloads triggered by UI actions
To collect all requests matching a pattern into an array, push matching requests into an array inside the request event handler and assert on the array after the action completes
Use page.waitForLoadState('networkidle') after an action to ensure all in-flight requests have settled before asserting on collected network data
Known gotchas
request and response events fire for every resource (scripts, images, fonts) not just XHR or fetch calls — filter by URL pattern or resource type using request.resourceType() to avoid noise
Response bodies are only accessible synchronously if the response event handler reads them immediately; buffering is not guaranteed for bodies read after the event fires — always await response.json() or response.text() inside the handler
Requests intercepted by a registered page.route() handler may show different timing and may not fire response events if the route aborts or short-circuits the request — be aware of interaction between route handlers and network event listeners
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