Puppeteer icon

Puppeteer

Request a webpage using Puppeteer

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, navigate pages, interact with page elements, handle captchas, manage cookies, take screenshots, and more.

Common scenarios include:

  • Automating web scraping tasks by navigating pages, waiting for selectors, and extracting content.
  • Performing automated testing or monitoring of web applications.
  • Handling login flows including captcha solving.
  • Uploading files or interacting with complex web forms.
  • Taking screenshots or generating PDFs of web pages.

For example, you can use this node to open a new browser page, navigate to a URL, wait for a specific element to appear, extract data via JavaScript evaluation, and then close the page — all within an automated workflow.

Properties

Name Meaning
Instance Identifier A unique string to identify and reuse the same browser and page instance across multiple nodes in a workflow.
Use 2Captcha solver (Optional) API key for the 2Captcha service to automatically solve 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 headless detection.
- 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 a browser target (tab/page) and switch to it.
Timeout Timeout duration in milliseconds for generic page operations like handling targets.
URL The URL to navigate to when performing a page navigation 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, wait for selector, or file upload.
Evaluate Selector (optional) Optional CSS selector to narrow down the scope for JavaScript evaluation on the page.
Text Text input to type into an element on the page.
Evaluation Loop Until Timeout Timeout in milliseconds to repeatedly evaluate a JavaScript function until success or timeout.
Cookies JSON object specifying cookies to set or delete on the page.
Options JSON object with additional options for various page operations such as navigation, clicking, typing, waiting for selectors, reloading, etc.
Javascript Function JavaScript code to run on the page context for evaluation operations.
Evaluate Args JSON object containing variables passed as arguments to the JavaScript evaluation function.

Output

The node outputs JSON objects representing the result of the performed browser or page operation. Typical output fields include:

  • For navigation: HTTP status code and response headers.
  • For interaction commands (click, type, hover): confirmation or error messages.
  • For evaluation: the result of the executed JavaScript function.
  • For screenshot: details about the saved image file.
  • For cookie operations: current cookies or confirmation of changes.
  • For captcha solving: solved captcha text or error information.

If an error occurs during any operation, the output JSON contains an error field describing the issue.

Binary data output is not directly handled by this node; instead, screenshots or files are saved externally with filenames provided as input.

Dependencies

  • Requires Puppeteer library for browser automation.
  • Optionally integrates with the 2Captcha service for captcha solving, requiring a valid API key.
  • May require access to a running browser instance or the ability to launch one locally.
  • Proxy servers can be configured if needed.
  • No internal credential names are exposed; users must provide appropriate API keys or tokens as plain strings.

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.
    • Captcha solving errors if the 2Captcha API key is missing or invalid.
    • Timeouts when waiting for selectors or navigation if the page is slow or unresponsive.
  • Error messages:

    • Errors returned from Puppeteer operations are surfaced in the output JSON under the error field.
    • HTTP request failures during navigation include status codes and headers for diagnosis.
    • To handle errors gracefully, enable "Continue On Fail" in the node settings to prevent workflow interruption.
  • Resolution tips:

    • Verify all input parameters, especially selectors and URLs.
    • Ensure the browser instance is accessible and properly configured.
    • Provide a valid 2Captcha API key if captcha solving is required.
    • Adjust timeouts and retry logic for slow-loading pages.

Links and References

Discussion