Actions7
- Robot Lifecycle Actions
- Context Actions
- Tool Actions
- Error Actions
Tool → Execute
AI-generatedSummary
Execute custom JavaScript code on a Puppeteer Robot instance, optionally running it in the page context, with control over execution timing and error handling behavior.
Inputs
- Code (required) — The JavaScript code to execute on the Puppeteer Robot. If "Run on Page Context" is enabled, this code is run inside the page context using page.evaluate().
- Run on Page Context — When enabled, runs the provided code inside the browser page context rather than the Node.js context.
- Sleep (Seconds) — Optional delay in seconds to wait after executing the code before continuing the workflow.
- On Error — Defines error handling behavior: continue on errors, throw exceptions on all errors, or throw only on non-user errors.
Output shape
A single JSON object containing the Puppeteer Robot context, execution memory data (including accumulated data and the last returned value), and the raw response from executing the code.
The node communicates with an external Puppeteer Robot server to execute the code. It handles multiple error states (function return error, robot not found, JavaScript exception) by optionally throwing exceptions as configured. Sleep durations over 64 seconds use n8n's wait mechanism. Execution results and context are accumulated across executions and exposed in the output.
Examples
Example 1: Execute JavaScript code in the page context with a 5-second delay and continue despite errors
Set "Code" with your script, enable "Run on Page Context", set "Sleep (Seconds)" to 5, and set "On Error" to Continue.