Network
Use network commands to intercept requests, mock responses, inspect traffic, and export HAR files during browser automation.
Request routing
Routes apply before matching requests are sent. Set them before navigation when you need the first page load to be affected.
| Command | Description |
|---|---|
network route <url> | Intercept matching requests |
network route <url> --abort | Block matching requests |
network route <url> --body <json> | Fulfill matching requests with a mock body |
network route "*" --resource-type script --abort | Block only a specific resource type |
network unroute [url] | Remove one route or all routes |
--resource-type accepts comma-separated resource types such as script, image, font, xhr, and fetch.
Request log
| Filter | Description |
|---|---|
--filter <pattern> | Filter by URL substring or pattern |
--type <csv> | Filter by resource type |
--method <method> | Filter by HTTP method |
--status <status> | Filter by exact status, status family, or range |
--clear | Clear the tracked request log |
Use network request <requestId> to inspect one request and response in detail after finding its ID in network requests.
HAR export
Text response bodies (JSON, HTML, JavaScript, form data) are embedded in the HAR as content.text by default, captured while the browser still has them buffered so they survive navigation. The --content flag on har start controls this:
| Mode | Behavior |
|---|---|
--content text | Default. Embed text-like bodies (JSON, XML, HTML, JS, form data), up to 2 MB per body. |
--content all | Embed every body; binary content is base64-encoded with encoding: "base64". |
--content none | Sizes and MIME types only, no bodies. |
HAR files include request headers, response headers, cookies, POST data, and response bodies. Treat them as sensitive when pages use cookies, bearer tokens, or API keys.
SSR and no-JavaScript debugging
Launching with open and no URL leaves the browser on about:blank, which gives routes time to register before the first real navigation.