Playwright icon

Playwright

Automate browser tasks with Playwright and optional CDP connection

Browser → Wait For Selector

AI-generated

Summary

Wait for an element matching a CSS selector to satisfy a specified state (visible, attached, hidden, or detached) on a browser page controlled by Playwright.

Inputs

  • Connection Mode — Choose whether to launch a new browser instance or connect to an existing one via Chrome DevTools Protocol (CDP).
  • Browser Type — Select the browser engine (Chromium, Firefox, WebKit) to launch; applicable only when launching a new browser.
  • Headless — Determine if the browser launches without a visible window; applicable when launching.
  • CDP Endpoint — Specify the URL endpoint for connecting over CDP; required for CDP connection mode.
  • Timeout (MS) — Maximum time in milliseconds to wait for the selector state before timing out.
  • Session ID — Identifier to reuse the same browser page session in subsequent nodes.
  • Use Existing Tab — Reuse an already open tab on the connected browser when using CDP connection mode.
  • Tab Index — Zero-based index of the tab to reuse when 'Use Existing Tab' is enabled.
  • Block Resource Types — List of resource types to block loading on newly created pages to reduce bandwidth.
  • Block URL Patterns — Comma-separated URL glob patterns to block on newly created pages.
  • Additional Data — Optional JSON data to include in the output for context or downstream use.
  • Target URL — URL to navigate to before waiting for the selector state.
  • Selector (required) — CSS selector identifying the target element to wait for.
  • Wait State — Desired condition of the element to wait for: visible, attached, hidden, or detached.
  • After Execution — Defines whether to close the browser, close the page/tab, or keep them open after the operation completes.

Output shape

a single JSON object per input item

Each output includes operation details such as selector, waitState, current page URL, session info (mode, sessionId, tabIndex), timestamp, and success flag. AdditionalData is included if provided. The browser and page are optionally closed or kept open based on the 'After Execution' setting.

Examples

Example 1: Wait until a button with id 'submit' becomes visible on the page before continuing

Set 'Selector' to '#submit', 'Wait State' to 'Visible', provide 'Target URL' to the page to check, and choose connection mode to launch or connect to the browser.

Links

Discussion