Playwright icon

Playwright

Control browser using Playwright directly with CDP URL

Goto

AI-generated

Overview

This node allows direct control of a Chromium browser instance using the Playwright library connected via a Chrome DevTools Protocol (CDP) URL. It enables automated browser interactions such as navigating to URLs, clicking elements, filling inputs, taking screenshots, waiting for page events, and more.

Common scenarios include:

  • Automated web testing or scraping by programmatically controlling a browser.
  • Capturing screenshots of web pages for monitoring or documentation.
  • Filling forms and simulating user input on websites.
  • Waiting for specific page states or elements before proceeding in a workflow.

For example, you can use this node to navigate to a webpage, wait for it to fully load, take a screenshot, and then extract data from the page.

Properties

Name Meaning
CDP URL Chrome DevTools Protocol URL to connect to the browser (e.g., ws://localhost:9222/...)
URL The URL to navigate to (used only in "Goto" operation)

Additional properties relevant to other operations (not requested but present):

  • Operation: The action to perform (e.g., Goto, Click, Fill, Screenshot).
  • Full Page: Whether to capture the full page in screenshots (boolean).
  • Quality: JPEG screenshot quality (0-100).
  • Selector: CSS selector for targeting elements.
  • Text: Text to fill or type into an element.
  • Key: Keyboard key to press on an element.
  • State: Load state to wait for (load, domcontentloaded, networkidle).
  • Duration (Ms): Time to wait in milliseconds.
  • Timeout (Ms): Maximum time to wait for selectors or load states.

Output

The node outputs an array of items corresponding to each input item processed. Each output item contains:

  • A json object with at least the field:
    • operation: The name of the operation performed (e.g., "goto").
  • For the "Screenshot" operation, the output also includes a binary property containing the screenshot image data:
    • screenshot: Binary data of the captured screenshot in JPEG format.

Other operations return only JSON confirming the operation was executed successfully.

Dependencies

  • Requires a running Chromium-based browser instance exposing a Chrome DevTools Protocol WebSocket URL.
  • Uses the Playwright library to connect and control the browser over CDP.
  • No internal credentials are required beyond access to the CDP URL.
  • Ensure the CDP URL is accessible from the environment where n8n runs.

Troubleshooting

  • Connection issues: If the node cannot connect to the CDP URL, verify that the browser is running with remote debugging enabled and that the URL is correct and reachable.
  • Unsupported operations: Attempting an unsupported operation will throw an error indicating the operation is not supported.
  • Invalid load state: Providing an invalid load state value will cause an error; valid values are "load", "domcontentloaded", and "networkidle".
  • Timeouts: Operations waiting for selectors or load states may timeout if the conditions are not met within the specified time.
  • Selector errors: Using incorrect or non-existent selectors will cause failures in click, fill, type, press, and waitForSelector operations.

Links and References

Discussion