Playwright CDP icon

Playwright CDP

Automate browser interactions using Playwright with remote browser via CDP

Run Custom Script

AI-generated

Summary

Execute JavaScript in a CDP-connected Playwright browser context; the script runs as an async function with access to $page, $context, $browser, $playwright, and $credentials, and must return an array of items.

Inputs

  • cdpEndpoint (required) — CDP endpoint URL to connect to the remote browser (e.g., http://localhost:9222 or ws://localhost:9222/devtools/browser/xxx)
  • authentication — Authentication method for the CDP connection (none or httpBasicAuth)
  • scriptCode (required) — JavaScript code to execute; must return an array (e.g., return [{ ip: ipData }]). Access to $browser, $context, $page, $playwright, and $credentials.
  • options — Collection of execution options for the browser context.

Output shape

array

Each item in the returned array corresponds to an input item (respecting batchSize). If the script does not return an array, the node throws: 'Custom script must return an array of items.' console.log() statements are forwarded to the workflow UI.

Examples

Example 1: Lookup the requester's IP address

Use the default script code provided in the node UI, which navigates to httpbin.org/ip and returns the origin field as { ip: '8.8.8.8' }.

Discussion