Version: 1.8.0
Network
Playwright provides APIs to monitor and modify network traffic, both HTTP and HTTPS. Any requests that page does, including XHRs and fetch requests, can be tracked, modified and handled.
#
HTTP Authentication#
API reference#
Network eventsYou can monitor all the requests and responses:
Or wait for a network response after the button click:
#
Variations#
API reference- Request
- Response
- page.on('request')
- page.on('response')
- page.waitForRequest(urlOrPredicate[, options])
- page.waitForResponse(urlOrPredicate[, options])
#
Handle requestsYou can mock API endpoints via handling the network quests in your Playwright script.
#
Variations#
API reference- browserContext.route(url, handler)
- browserContext.unroute(url[, handler])
- page.route(url, handler)
- page.unroute(url[, handler])
- Route
#
Modify requestsYou can continue requests with modifications. Example above removes an HTTP header from the outgoing requests.