Execute Playwright/TypeScript code against the browser

Execute arbitrary Playwright code in a fresh execution context against the browser. The code runs in the same VM as the browser, minimizing latency and maximizing throughput. It has access to 'page', 'context', and 'browser' variables. It can `return` a value, and this value is returned in the response.

POST/browsers/{id}/playwright/execute

Execute arbitrary Playwright code in a fresh execution context against the browser. The code runs in the same VM as the browser, minimizing latency and maximizing throughput. It has access to 'page', 'context', and 'browser' variables. It can return a value, and this value is returned in the response.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

id*string

Browser session ID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to execute Playwright code

Response

application/json

Code executed successfully

Result of Playwright code execution

curl -X POST "https://example.com/browsers/string/playwright/execute" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "success": true,  "result": null,  "error": "string",  "stdout": "string",  "stderr": "string"}