Execute Playwright/TypeScript code against the browser

Execute arbitrary Playwright code in a fresh execution context against the browser running on localhost:9222. The code has access to 'page', 'context', and 'browser' variables. The result of the code execution is returned in the response.

'page' is bound to an active tab reported by Chrome. In single-window sessions, this is the foreground tab. When multiple browser windows are open, Chrome reports one active tab per window and the selected window is unspecified. 'context' is the BrowserContext that owns the selected page. If active-tab resolution races with a target change, execution falls back to an existing page. Use 'browser.contexts()' to select a context or page explicitly.

post/playwright/execute

Request body

codestring required

TypeScript/JavaScript code to execute. The code has access to 'page', 'context', and 'browser' variables. Example: "await page.goto('https://example.com'); return await page.title();"

timeout_secinteger

Maximum execution time in seconds. Default is 60.

Response

Code executed successfully

successboolean required

Whether the code executed successfully

{"stackTrail":"components:schemas:ExecutePlaywrightResult:properties:result","oasType":"schema","type":"unknown","description":"The value returned by the code (if any)"}
errorstring

Error message if execution failed

stdoutstring

Standard output from the execution

stderrstring

Standard error from the execution

Changes