Actions12
Browser → Run Script
AI-generatedSummary
Execute a custom asynchronous Playwright script within a browser page, optionally reusing or creating a new browser session, and control the browser's lifecycle post-execution.
Inputs
- Connection Mode (required) — Choose how to connect to the browser: either launch a new browser instance or connect to an existing one via Chrome DevTools Protocol (CDP).
- Browser Type — Select the browser engine to launch (Chromium, Firefox, or WebKit); applicable only when launching a browser.
- Headless — Specify if the launched browser should run without a visible UI; only applicable in launch mode.
- CDP Endpoint — Provide the Chrome DevTools Protocol endpoint URL to connect over CDP; required if connection mode is CDP.
- Timeout (MS) — Set the maximum time in milliseconds to wait for browser actions.
- Session ID — Define an identifier to reuse the same browser session and page across multiple nodes.
- Use Existing Tab — Indicate whether to reuse an already open tab in the connected browser; applicable only in CDP mode.
- Tab Index — Specify the zero-based index of the tab to reuse when reusing an existing tab.
- Block Resource Types — List resource types to block and abort during page load to reduce bandwidth; only applies when a new page is created.
- Block URL Patterns — Provide comma-separated glob patterns of URLs to block during page load; only applies when a new page is created.
- Additional Data — Include optional JSON data to add to the operation's output.
- Custom Script (required) — Write an asynchronous JavaScript script using the Playwright API on the available $page, $context, and $browser objects; this script must return data to output items.
- After Execution (required) — Choose what to do with the browser after the script completes: close the entire browser, close only the current page/tab, or keep both open for reuse.
Output shape
a list of output items, each with JSON data that includes script-returned data merged with metadata about the session, URL, success status, and optionally additional data
The output items correspond to the returned data from the custom script. If the script returns an array of objects, each object becomes a separate output item merged with operation metadata. If it returns a single object or primitive, these merge into or attach as a 'result' field, respectively. The output always includes details like session ID, URL of the active page, connection mode, tab index, and a success flag. Resource blocking applies only on new page creation, and session management supports reusing browser contexts and tabs.