Actions4
Overview
This node provides a comprehensive interface to control and interact with browser pages using Puppeteer within n8n workflows. It allows users to perform various page-level operations such as navigating to URLs, clicking elements, typing text, taking screenshots, handling cookies, evaluating JavaScript on the page, solving captchas via 2Captcha service, and more.
Common scenarios where this node is beneficial include:
- Automating web scraping tasks by navigating pages, extracting content, and interacting with page elements.
- Automating form filling and submission.
- Taking screenshots of web pages for monitoring or reporting.
- Handling authentication flows that require interaction with page elements.
- Solving captchas automatically during automation.
- Managing cookies for session handling.
Practical example: A user can automate logging into a website by navigating to the login page (Page Go To
), typing username and password (Type
), clicking the login button (Click
), waiting for navigation (Wait For Navigation
), and then extracting some protected content (Page Evaluate
).
Properties
Name | Meaning |
---|---|
Instance Identifier | A unique identifier for the browser and page instance, used to reference the same instance in multiple nodes. |
Use 2Captcha solver | The API key for the 2Captcha service to solve captchas (only shown when creating a new browser page). |
Browser Options | Collection of options to configure the browser instance when creating a new page, including: - Browser WSEndpoint: Connect to an existing browser 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 headless detection. - Proxy Server: Custom proxy configuration. - Slow Mo: Slow down Puppeteer operations by specified milliseconds. - Headless mode: Whether to run browser in headless mode or show full window. |
Page Operation | The specific operation to perform on the page. Options include: - Page Go To: Navigate to a URL. - Page Go Back: Navigate back. - Page Go Forward: Navigate forward. - Page File Choose: Upload file. - Page Reload: Reload page. - Page close: Close page. - Page Screenshot: Take screenshot. - Page evaluate: Run JS function. - Add Script Tag: Inject script tag. - Click: Click element. - Type: Type text. - Content: Get page content. - Cookies: Get cookies. - Delete Cookie: Delete cookie. - Set Cookies: Set cookies. - Hover: Hover over element. - Wait For Selector: Wait for element. - Wait For Navigation: Wait for navigation. - Solve Captcha: Use 2Captcha to solve captcha. - Page target: Handle page target. |
Close target | Boolean flag to close the target and switch to it (used with Page target operation). |
Timeout | Timeout value in milliseconds for certain operations (used with Page target operation). |
URL | The URL to navigate to (used with Page Go To operation). |
Filename | Filename for saving screenshots or choosing files for upload (used with Page Screenshot and Page File Choose operations). |
IFrame Selector | Optional CSS selector of an iframe to interact with (used with operations like Evaluate, Wait For Selector, Click, Type, Hover). |
Selector | CSS selector of the element to interact with (used with Click, Type, Hover, Wait For Selector, Page File Choose operations). |
Evaluate Selector | Optional CSS selector to narrow down evaluation context (used with Page Evaluate operation). |
Text | Text to type into an element (used with Type operation). |
Evaluation Loop Until Timeout | Timeout in milliseconds to keep evaluating until condition met (used with Page Evaluate operation). |
Cookies | JSON object specifying cookies to delete or set (used with Delete Cookie and Set Cookies operations). |
Options | JSON object with additional options for various page operations like Click, Go Back, Go Forward, Reload, Wait For Selector, Wait For Navigation, Add Script Tag, etc. |
Javascript Function | JavaScript code to execute on the page (used with Page Evaluate operation). |
Evaluate Args | JSON object of variables to pass to the evaluate function (used with Page Evaluate operation). |
Output
The node outputs JSON data representing the result of the performed page operation. The structure varies depending on the operation:
- For navigation (
Page Go To
), output includes HTTP status code and response headers. - For screenshot (
Page Screenshot
), output includes confirmation and metadata about the saved image file. - For element interactions (
Click
,Type
,Hover
), output confirms success or error details. - For
Page Evaluate
, output contains the result of the executed JavaScript function. - For cookie operations, output includes current cookies or confirmation of deletion/set.
- For captcha solving, output includes the solved captcha token or error.
- For other operations, output generally contains success confirmation or error messages.
If an error occurs during any operation, the output JSON will contain an error
field describing the issue unless the node is configured to continue on failure.
Binary data output is not directly handled by this node; screenshots are saved as files referenced by filename property.
Dependencies
- Requires Puppeteer library for browser automation.
- Optionally requires a 2Captcha API key credential if using the captcha solving feature.
- No internal credential names are exposed; users must provide their own API keys or tokens as needed.
- The node manages browser instances identified by the "Instance Identifier" string to allow reuse across workflow nodes.
Troubleshooting
Common issues:
- Failure to connect to a browser instance if the provided instance identifier does not correspond to a running browser.
- Navigation failures due to invalid URLs or network issues.
- Selector not found errors when the specified CSS selector does not exist on the page.
- Timeout errors if waiting for selectors or navigation takes too long.
- Captcha solving failures if the 2Captcha API key is invalid or quota exceeded.
- Errors when trying to interact with iframes if the iframe selector is incorrect.
Error messages and resolutions:
"Request failed with status code XXX"
: The page navigation returned an HTTP error. Verify the URL and network connectivity."Selector not found"
: Check the correctness of the CSS selector and ensure the element exists on the page."Captcha solving error"
: Confirm the 2Captcha API key is valid and has sufficient balance."Browser instance not found"
: Ensure the browser instance is started and the instance identifier matches."Timeout exceeded"
: Increase timeout values or verify page responsiveness.
Users can enable "Continue On Fail" option in the node to handle errors gracefully without stopping the workflow.