---
title: "Execute JavaScript in the device's Chrome browser (CDP)"
method: POST
path: "/devices/{deviceId}/browser/execute-script"
tags: ["Browser"]
---

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

`POST /devices/{deviceId}/browser/execute-script`

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.

## Path parameters

- `deviceId` string, required

## Headers

- `X-Device-Display-ID` integer

## Request body

- ExecuteScriptArgs
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `script` string, 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 })().

## Response `200`

OK

- ExecuteScriptOutputBody
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `result` unknown, required

## Other responses

- `default` — Error

---

[API](https://skmtc.net/mobilerun/apis/workflows.md) · [All operations](https://skmtc.net/mobilerun/apis/workflows/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mobilerun/workflows/revisions/1bc499aa8f99/schema)
