webpage_mock_add
Add (or update in place, when id matches an existing route) a mock/abort rule for browser requests on this device. mode "mock" (default) serves the given status/headers/body without the request leaving the device; mode "abort" fails it so the page sees a network error. Routes apply immediately and survive navigation. WEB CONTENT ONLY: this intercepts requests made by browser/WebView pages. Requests made by native app code are NOT intercepted and never will be by this tool. Nothing device-wide is changed and no certificate is installed — the effect is scoped to the page. For requests made by native app code use android_traffic_mock_add / ios_traffic_mock_add instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Route id to update in place; omit to auto-generate a new one | |
| body | No | Response body for mode "mock" (text, or base64 when bodyEncoding is "base64") | |
| mode | No | "mock" serves a canned response (default); "abort" fails the request | |
| udid | Yes | Device id (Android serial or iOS UDID) | |
| method | No | Optional HTTP method filter (e.g. "GET"/"POST"); matches any method when omitted | |
| pageId | No | Pin routing to a specific page id (from the *_list_pages tool). Omit to follow the active page automatically across navigations and new tabs — recommended. | |
| socket | No | Abstract unix socket name (default: chrome_devtools_remote) | |
| status | No | HTTP status to serve for mode "mock" (default 200) | |
| delayMs | No | Latency injected before responding/failing, in ms (clamped to 60s) | |
| enabled | No | Whether the route is active (default true) — disabled routes are kept but ignored | |
| headers | No | Response headers for mode "mock", as {headerName: value} — e.g. {"content-type": "application/json"}. On iOS a `charset` in content-type is NOT applied to the response: an HTML body with non-ASCII characters must declare it in the document (e.g. <meta charset="utf-8">) or it will be decoded with the default encoding and render as mojibake. | |
| matchUrl | Yes | URL pattern to match against the request's full URL | |
| matchType | No | How matchUrl is interpreted against the request URL (default "contains") | |
| bodyEncoding | No | Encoding of `body` (default "text") |