Playwright icon

Playwright

Automate browser interactions using Playwright

Overview

This node uses the Playwright library to interact with web pages programmatically. Specifically, the "Get Screenshot" operation captures a screenshot of a given URL and returns it as binary image data. It supports capturing the full scrollable page or just the visible viewport, and allows choosing the image format (PNG, JPEG, WebP) and quality settings.

Common scenarios where this node is beneficial include:

  • Automatically generating website previews or thumbnails.
  • Monitoring visual changes on web pages over time.
  • Archiving snapshots of dynamic content for reports or audits.
  • Creating images from web pages for social media sharing or documentation.

For example, you could use this node to take a full-page PNG screenshot of a product page URL and save the image in your workflow for further processing or storage.

Properties

Name Meaning
URL The web address of the page to capture. Must be a valid URL string.
Property Name The name of the binary property where the screenshot image will be stored in the output.
Type The image format for the screenshot. Options: PNG, JPEG, WebP.
Quality Image quality between 0-100, applicable only for JPEG and WebP formats. Not used for PNG.
Full Page Whether to capture the entire scrollable page (true) or just the visible viewport (false).
Query Parameters Optional query parameters to append to the URL before loading the page. Each parameter has a name and value.
Batch Size Maximum number of pages to open simultaneously during execution. Higher values increase resource usage.
Browser WebSocket Endpoint Optional WebSocket URL to connect to an existing browser instance instead of launching a new one.
Emulate Device Optionally emulate a specific device's viewport and user agent (e.g., mobile devices).
Executable Path Path to a custom browser executable to use instead of the bundled one. Ignored if connecting via WebSocket.
Extra Headers Additional HTTP headers to send with the page request.
File Name Filename to assign to the binary data output. Only applies to screenshot and PDF operations.
Launch Arguments Additional command line arguments to pass to the browser process. Ignored if connecting via WebSocket.
Timeout Maximum navigation time in milliseconds before aborting. Set to 0 to disable timeout.
Protocol Timeout Maximum time to wait for protocol responses in milliseconds. Set to 0 to disable timeout.
Wait Until When to consider navigation successful. Options: load (page load event), domcontentloaded (DOM ready), networkidle (no network connections for 500ms).
Page Caching Enable or disable page-level caching. Defaults to enabled.
Headless mode Run the browser in headless mode (no UI). Defaults to true.
Proxy Server Custom proxy server configuration (e.g., localhost:8080, socks5://localhost:1080).
Add Container Arguments Whether to add recommended browser arguments for container environments (e.g., --no-sandbox). Defaults to true.

Output

The node outputs an array of items corresponding to each input item processed. For the "Get Screenshot" operation, each output item contains:

  • A binary property with the screenshot image data stored under the user-defined property name. This binary data includes the image buffer and metadata such as mime type (image/png, image/jpeg, or image/webp) and filename if specified.
  • A json property containing metadata about the HTTP response, including:
    • headers: The HTTP response headers from the page request.
    • statusCode: The HTTP status code returned by the page.
    • url: The final URL loaded (including any appended query parameters).

This structure allows downstream nodes to access both the raw image data and relevant HTTP information.

Dependencies

  • Playwright: The node relies on the Playwright library to launch or connect to Chromium-based browsers for rendering pages and capturing screenshots.
  • Browser Executable: Requires a Chromium browser executable either bundled with Playwright or specified via the executable path.
  • Optional External Browser Connection: Can connect to an existing browser instance via a WebSocket endpoint.
  • n8n Environment Variables: Supports environment variables to configure allowed built-in/external modules and executable paths.
  • API Keys / Credentials: No direct API keys are required, but if using proxies or authenticated devices, appropriate credentials/configurations may be needed externally.

Troubleshooting

  • Failed to launch/connect to browser: Indicates issues starting the Chromium browser or connecting to a remote instance. Check that the executable path is correct, the WebSocket endpoint is reachable, and required dependencies are installed.
  • Invalid URL error: Occurs if the provided URL is malformed or cannot be parsed. Ensure URLs are valid and properly formatted.
  • Request failed with status code >= 400: The target page returned an error status. Verify the URL is accessible and not blocked by firewalls or authentication.
  • Timeout errors: Navigation or protocol timeouts can happen if the page takes too long to load. Adjust the timeout properties or check network conditions.
  • Failed to capture screenshot: Could be due to page rendering issues or unsupported options. Try disabling full page capture or changing image type.
  • Resource limits exceeded: Using large batch sizes or multiple simultaneous pages can exhaust memory/CPU. Reduce batch size accordingly.
  • Container environment issues: If running inside containers, ensure container arguments are enabled or manually add necessary flags like --no-sandbox.

Links and References

Discussion