Actions4
Overview
This node provides a comprehensive interface to control and automate browser actions using Puppeteer within n8n workflows. It allows users to launch or connect to browser instances, open new pages, navigate URLs, interact with page elements (click, type, hover), handle cookies, take screenshots, evaluate JavaScript on pages, solve captchas via 2Captcha, and more.
Common scenarios include:
- Automating web scraping tasks by navigating pages and extracting content.
- Testing web applications by simulating user interactions.
- Automating form filling and submission.
- Capturing screenshots of web pages for monitoring or reporting.
- Handling complex navigation flows including waiting for selectors or navigation events.
- Solving captchas automatically during automation.
Practical example:
- A workflow that opens a browser page, navigates to a login page, fills in credentials, solves any captcha encountered, submits the form, waits for navigation, and then extracts some data from the resulting page.
Properties
Name | Meaning |
---|---|
Instance Identifier | A unique string to identify and reuse the same browser and page instance across multiple nodes. |
Use 2Captcha solver | API key for the 2Captcha service to enable automatic solving of captchas encountered during browsing. |
Browser Options | Collection of options when launching or connecting to a browser instance: - Browser WSEndpoint: Connect to an existing browser via websocket endpoint. - Emulate Device: Choose a device profile to emulate. - Launch Arguments: Additional command line arguments for the browser. - Handle Browser Close/Disconnect/Target: Flags to handle browser lifecycle events. - Stealth mode: Enable techniques to avoid detection as headless browser. - Proxy Server: Configure proxy settings. - Slow Mo: Delay operations by specified milliseconds. - Headless mode: Run browser in headless or full UI mode. |
Close target | Whether to close the current target (page) and switch to it. |
Timeout | Timeout value in milliseconds for certain page operations like handling targets. |
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. |
Selector | CSS selector for targeting elements on the page for actions like click, type, hover, waitForSelector, chooseFile. |
Evaluate Selector | Optional selector used in page evaluation operations to narrow down the scope. |
Text | Text to type into an element during typing operations. |
Evaluation Loop Until Timeout | Timeout in milliseconds for repeated evaluation loops during page evaluation. |
Cookies | JSON object specifying cookies to set or delete on the page. |
Options | JSON object with additional options passed to various page operations such as click, goto, type, reload, waitForSelector, waitForNavigation, addScriptTag, goBack, goForward. |
Javascript Function | JavaScript code string to be executed on the page during evaluation operations. |
Evaluate Args | JSON object containing variables to pass as arguments to the evaluation function. |
Output
The node outputs JSON objects representing the result of the performed browser or page action. The structure varies depending on the operation but generally includes:
- For browser actions (e.g., newPage, closeBrowser): status information about the browser instance.
- For page navigation (pageGoto): HTTP response headers and status code.
- For interactions (click, type, hover, waitForSelector, etc.): success confirmation or error details.
- For pageEvaluate: the result of the executed JavaScript function.
- For pageScreenshot: confirmation of screenshot saved.
- For cookie operations: current cookies or confirmation of changes.
- For captcha solving: solved captcha text or error.
- For other page operations: relevant metadata or error messages.
If an error occurs and "Continue On Fail" is not enabled, the node throws an error; otherwise, it returns an object with an error
field describing the issue.
Binary data output is not explicitly handled by this node; screenshots are saved to files specified by filename properties.
Dependencies
- Requires Puppeteer library for browser automation.
- Optionally requires a 2Captcha API key credential if captcha solving is enabled.
- May require access to a running browser instance or ability to launch one locally.
- Proxy server configuration can be used if needed.
- No internal credential names are exposed; users must provide their own API keys and endpoints.
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 the CSS selector does not match any element on the page.
- Timeouts when waiting for selectors or navigation if the page is slow or the selector never appears.
- Captcha solving failures if the 2Captcha API key is missing, invalid, or quota exceeded.
- Errors when trying to perform actions on closed or disconnected browser/page instances.
Error messages:
"Request failed with status code XXX"
: Indicates HTTP navigation returned an error status; verify URL and network.- Errors containing
"error"
field in output JSON: Check the message for specific failure reason. - If the node throws an error and the workflow stops, consider enabling "Continue On Fail" to handle errors gracefully.
Resolutions:
- Verify all input parameters, especially instance identifiers and selectors.
- Ensure the browser instance is running or can be launched.
- Provide valid 2Captcha API key if captcha solving is required.
- Increase timeouts for slow-loading pages.
- Use correct CSS selectors matching the page structure.