Actions4
Overview
This node integrates Puppeteer, a browser automation library, into n8n workflows. It allows users to programmatically control a browser instance and perform various browser and page operations such as opening new pages, navigating to URLs, clicking elements, typing text, taking screenshots, handling cookies, solving captchas, and more.
Common scenarios include:
- Automating web scraping tasks by navigating pages and extracting content.
- Testing web applications by simulating user interactions.
- Automating form submissions or file uploads.
- Handling captcha challenges automatically using 2Captcha service.
- Managing multiple browser instances or pages within a workflow.
For example, you can use this node to open a new browser page, navigate to a product listing, click on items, take screenshots, and extract data for further processing.
Properties
Name | Meaning |
---|---|
Instance Identifier | A unique string to identify and reuse the same browser and page instance across multiple nodes in the workflow. |
Action (browserActions) | For browser context: choose between "New Page" (create a new page in the browser instance) or "Close" (close the browser instance). |
Use 2Captcha solver | Optional API key for the 2Captcha service to solve captchas automatically when opening a new page. |
Browser Options | Collection of options to configure the browser instance when creating a new page, including: - Browser WSEndpoint: Connect to an existing browser via websocket endpoint. - Emulate Device: Select a device profile. - Launch Arguments: Additional command line arguments for the browser. - Handle Browser Close/Disconnect/Target: Boolean flags to handle browser lifecycle events. - Stealth mode: Enable techniques to avoid detection of headless browser. - Proxy Server: Configure proxy settings. - Slow Mo: Delay operations by specified milliseconds. - Headless mode: Run browser in headless or full window mode. |
Close target | When performing a page target operation, whether to close the target and switch to it. |
Timeout | Generic timeout value (in ms) for some page target operations. |
URL | The URL to navigate to when performing a page goto operation. |
Filename | Filename used for saving screenshots or choosing files to upload. |
IFrame Selector | Optional CSS selector to specify an iframe within the page to interact with for certain operations like evaluate, wait for selector, click, type, hover. |
Selector | CSS selector for targeting elements on the page for operations like click, type, hover, wait for selector, choose file. |
Evaluate Selector (optional) | Optional selector to narrow down the scope for evaluation scripts on the page. |
Text | Text to type into an element during the page type operation. |
Evaluation Loop Until Timeout | Timeout (in ms) for repeated evaluation attempts during page evaluate operation. |
Cookies | JSON object specifying cookies to set or delete on the page. |
Options | JSON object with additional options for various page operations like add script tag, click, goto, type, navigation, reload, wait for selector/navigation. |
Javascript Function | JavaScript code to run on the page during the page evaluate operation. |
Evaluate Args | JSON object with variables passed as arguments to the evaluate function. |
Output
The node outputs JSON objects containing the results of the performed browser or page operation. The structure varies depending on the operation:
- For browser actions like "New Page" or "Close", output includes status or error messages.
- For page navigation ("pageGoto"), output includes HTTP response headers and status code.
- For interactions like click, type, screenshot, evaluate, etc., output contains success confirmation or error details.
- For pageEvaluate, output includes the result of the executed JavaScript function.
- For cookie operations, output reflects the current state or changes applied.
- For screenshot and file chooser operations, binary data is handled internally but not exposed directly; filenames are used to reference saved files.
If an error occurs and "Continue On Fail" is disabled, the node throws an error; otherwise, it returns an error message in the JSON output.
Dependencies
- Requires Puppeteer library for browser automation.
- Optionally requires a 2Captcha API key if captcha solving is enabled.
- May connect to an existing browser instance via WebSocket endpoint if configured.
- No internal credential names are exposed; users must provide necessary API keys or tokens as plain strings.
- No special environment variables required beyond standard n8n setup.
Troubleshooting
Common issues:
- Failure to connect to a browser instance if the WebSocket endpoint is incorrect or unavailable.
- Navigation failures due to invalid URLs or network issues.
- Selector not found errors if CSS selectors do not match any elements on the page.
- Captcha solving failures if the 2Captcha token is missing or invalid.
- Timeout errors if page operations take too long or hang.
Error messages:
- Errors returned from Puppeteer core functions are propagated as JSON error fields or thrown exceptions.
- HTTP status codes other than 200 during navigation cause errors unless "Continue On Fail" is enabled.
- Missing required parameters (e.g., instance identifier, URL, selector) will cause immediate errors.
Resolutions:
- Verify all input parameters carefully.
- Ensure the browser instance is running and accessible if connecting externally.
- Use correct and tested CSS selectors.
- Provide valid 2Captcha API key if captcha solving is needed.
- Adjust timeouts or enable "Continue On Fail" to handle intermittent failures gracefully.