Page Action icon

Page Action

Perform actions on browser pages

Overview

This node enables automated browser interactions within an n8n workflow. It allows users to control a browser instance to perform various actions such as navigating to URLs, clicking elements, typing text, waiting for elements, taking screenshots, and extracting HTML or text content from web pages.

Common scenarios include:

  • Automating web scraping tasks by navigating to pages and extracting data.
  • Testing web applications by simulating user interactions like clicks and text input.
  • Capturing visual snapshots of web pages for monitoring or documentation.
  • Waiting for dynamic page elements to load before proceeding with further automation steps.

For example, you could use this node to open a product page on an e-commerce site, wait for the price element to appear, extract the price text, and then take a screenshot of the page.

Properties

Name Meaning
Browser Name or ID Select an existing browser instance by name or ID from a list of eternal browsers, or leave empty to use a default custom name.
Custom Browser Name Provide a unique identifier for the browser instance that overrides the selected browser name. If both are empty, a default name based on execution ID is used.
Page ID Identifier for the page to operate on within the browser instance. Defaults to a value based on execution ID if left empty.
Action The action to perform on the page. Options:
• Go to URL — Navigate to a specified URL.
• Click Element — Click on a page element.
• Input Text — Type text into an input field.
• Wait for Element — Wait for an element to appear.
• Take Screenshot — Capture a screenshot.
• Get HTML — Retrieve HTML content.
• Get Text — Retrieve text content.
URL The URL to navigate to (required when Action is "Go to URL").
Selector Type The type of selector used to identify elements: CSS Selector or XPath. Used for actions targeting elements (Click, Input Text, Wait for Element, Get Text).
Selector The selector string identifying the target element (required for element-targeting actions).
Wait Options Options for waiting behavior when waiting for an element:
• Timeout (ms): Maximum wait time.
• Wait Until Visible: Wait until element is visible.
• Wait Until Hidden: Wait until element is hidden or removed.
Text The text to type into the selected element (required for Input Text action).
Type Options Options for typing behavior:
• Delay (ms): Delay between key presses.
Screenshot Options Options for taking screenshots:
• Full Page: Capture entire scrollable page.
• Output Field Name: Binary field name to store screenshot.
• Encoding: Binary or Base64 encoding of the screenshot output.
HTML Options Options for getting HTML:
• Element Selector: Optional selector to get HTML of a specific element.
• Selector Type: CSS or XPath.
• Include Outer HTML: Whether to include the outer HTML of the element.
Text Options Options for getting text:
• Trim: Whether to trim whitespace from extracted text.

Output

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

  • json.result: The result of the performed action. This varies depending on the action:
    • For navigation or click actions, it may be a status or confirmation.
    • For "Get HTML" or "Get Text", it contains the extracted content.
    • For "Wait for Element", it indicates success or timeout.
  • json.browserName: The name or ID of the browser instance used.
  • json.pageId: The page identifier used.

If the action produces binary data (e.g., a screenshot), the output includes a binary property with the screenshot stored under the configured field name. The screenshot can be encoded as raw binary or Base64 string depending on settings.

Dependencies

  • Requires access to a browser management system capable of handling multiple browser instances and pages.
  • Needs an API or service managing eternal browser instances (referred to generically).
  • No explicit external API keys are mentioned, but proper environment setup for browser automation is necessary.
  • The node depends on internal modules for executing browser actions.

Troubleshooting

  • Common issues:

    • Incorrect or missing selectors causing element not found errors.
    • Timeouts when waiting for elements that never appear.
    • Navigation failures due to invalid URLs or network issues.
    • Permission or environment issues preventing browser instantiation.
  • Error messages:

    • Errors related to element selection usually indicate incorrect selector syntax or timing issues; verify selectors and consider increasing wait time.
    • Navigation errors suggest checking URL validity and network connectivity.
    • If the node throws errors about browser instances, ensure the browser management system is properly configured and running.
  • To handle errors gracefully, enable "Continue On Fail" in the node settings to allow workflow continuation despite individual item failures.

Links and References

  • n8n Expressions Documentation
  • General browser automation concepts (e.g., Puppeteer or Playwright docs) may help understand selectors and actions.

Discussion