v1

latestOpenAPI 3.1.02026-07-22154213404.8 KB
Browser

Execute JavaScript in the device's Chrome browser (CDP)

Evaluates a JavaScript expression in the device's foreground Chrome tab via the Chrome DevTools Protocol and returns its JSON-serialized result. Devices without browser support return an unsupported-feature error.

post/devices/{deviceId}/browser/execute-script

Path parameters

deviceIdstring required

Headers

X-Device-Display-IDinteger

Request body

$schemastring uri

A URL to the JSON Schema for this object.

scriptstring required

JavaScript expression to evaluate in the device's foreground Chrome tab (CDP Runtime.evaluate). It is an expression, not a function body — the expression's value is returned (no top-level 'return'). Must evaluate to a JSON-serializable value; wrap multi-statement logic in an IIFE, e.g. (() => { ... ; return x })().

Example request

{
  "$schema": "https://example.com/schemas/ExecuteScriptArgs.json"
}

Response

OK

$schemastring uri

A URL to the JSON Schema for this object.

{"stackTrail":"components:schemas:ExecuteScriptOutputBody:properties:result","oasType":"schema","type":"unknown","description":"JSON-serialized return value of the script (null if it returned undefined). Non-JSON-serializable numbers (Infinity, NaN, -0) are returned as their string representation."}

Example response

{
  "$schema": "https://example.com/schemas/ExecuteScriptOutputBody.json"
}