ios_safari_evaluate
Evaluate a JavaScript expression in the context of a Safari page on an iOS device via the Web Inspector. Uses Runtime.evaluate internally. Returns the result as a string (JSON-stringified for objects), followed by a second block naming the tab it actually ran on — check that if a result looks like it came from the wrong page. Omit pageId to auto-pick the frontmost Safari tab. WAITING: UI frameworks paint a frame or two AFTER the click that triggers them, so an evaluate fired immediately can read the DOM before the menu/overlay/row exists. Use waitForSelector to block until an element appears (and waitMs to let it settle) INSTEAD of splitting the work into a separate poll call — both wait inside this same call on the same tab. DO NOT CLICK WITH THIS TOOL. A click dispatched from JavaScript — .click(), or dispatchEvent of a MouseEvent — is an untrusted event (isTrusted false). Component frameworks and anything gated on a real user gesture (file pickers, clipboard, autoplay, anti-bot checks) may ignore it, so the evaluate SUCCEEDS and the page does nothing — a failure that looks like a passing call. Use webpage_click instead: it has the device tap its own screen at the element, delivering a real trusted touch (pointerdown, touchstart, mousedown, click). Same for typing — webpage_type.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| udid | Yes | iOS device UDID | |
| pageId | No | CDP target id from ios_safari_list_pages. Omit it to use the page ios_safari_navigate last landed on (or, failing that, the first loaded page) — only pass it to target a DIFFERENT tab | |
| waitMs | No | Settle delay applied just before evaluating (and AFTER waitForSelector matches, when both are given). Use for animations that have started but not finished. Maximum 10000 ms | |
| expression | Yes | JavaScript expression to evaluate | |
| waitTimeoutMs | No | How long waitForSelector may poll. Default 5000 ms, maximum 15000 ms | |
| platformVersion | No | Ignored (kept for compatibility) | |
| waitForSelector | No | CSS selector to wait for BEFORE evaluating. Polls until it matches, then runs the expression. Errors if it never appears within waitTimeoutMs — it will not evaluate anyway and hand back a null that reads like a real answer |