Playwright icon

Playwright

Automate browser tasks with Playwright and optional CDP connection

Browser → Select Option

AI-generated

Summary

Select an option in a dropdown menu on a webpage by targeting a CSS selector and specifying the option to select by its value, label, or index.

Inputs

  • Connection Mode (required) — Select whether to launch a new browser or connect over CDP (Chrome DevTools Protocol).
  • Browser Type (required) — Choose the browser type to launch (Chromium, Firefox, WebKit); applicable only when launching a browser.
  • Headless (required) — Run the launched browser in headless mode or with a visible window (only if launching).
  • CDP Endpoint (required) — Specify the CDP endpoint URL when connecting over CDP.
  • Timeout (MS) (required) — Maximum duration to wait for browser actions.
  • Session ID — Optional ID to reuse the same browser session and page across nodes.
  • Use Existing Tab — (CDP mode only) Whether to reuse an existing browser tab.
  • Tab Index — (CDP mode with reuse active) Zero-based index of browser tab to reuse.
  • Block Resource Types — Resource types (e.g. images, scripts) to block to reduce bandwidth when a new page is created.
  • Block URL Patterns — Comma-separated URL glob patterns to abort requests matching them on a new page.
  • Additional Data — Optional JSON data to include in the node output.
  • Target URL — URL to navigate to before selecting the option.
  • Selector (required) — CSS selector identifying the dropdown element to operate on.
  • Option Value (required) — The value, visible label text, or index specifying which option to select in the dropdown.
  • After Execution (required) — Specify whether to close the browser, close the tab, or keep them open after the operation.

Output shape

a single JSON object containing operation details and status

The output confirms the CSS selector, the selected option's value, current page URL, and a success flag. Additional fields include connection mode, session ID, tab index, timestamp, optional CDP endpoint, and any additional user-provided data.

Examples

Example 1: Selecting an option in a dropdown

Launch a Chromium browser in headless mode, navigate to a specified target URL, select the option with value 'option-value' for the dropdown matching '#dropdown', then close the browser afterwards.

Links

Discussion