Playwright icon

Playwright

Automate browser actions using Playwright

Get Text

AI-generated

Summary

Reads the text content of the first element matching a CSS selector or XPath on the current page of a remote Playwright browser session, and returns it with the page URL.

Inputs

  • selectorType — CSS Selector (default) or XPath. Decides which of the two selector fields is used.
  • selector (required) — CSS selector of the target element (shown when Selector Type is CSS). Only the first match is used.
  • xpath (required) — XPath expression of the target element (shown when Selector Type is XPath). Only the first match is used.
  • browser — Browser type to connect with: Firefox (default) or Chrome (chromium).
  • browserEndpoint — Remote Playwright endpoint (e.g. ws://playwright:3000). If empty, falls back to the session's stored endpoint or the one passed by a preceding Playwright node. An error is thrown if none is found.
  • leaveSessionOpen — Keep the browser session open for the next Playwright node (default true). If false, the session is closed after this operation.
  • browserOptions — Collection with connection Timeout in ms (default 30000), Ignore SSL Issues, and a custom Session ID. Set Session ID manually if the previous node is not a Playwright node.

Output shape

One item per input item, with json fields: text (the element's textContent), selectorType, selector (the CSS or XPath used), url (current page URL), and playwright (sessionKey and browserEndpoint, for chaining to later Playwright nodes).

The operation does not navigate. A prior Navigate step must have loaded the page in the same session. textContent can be null if the node has no text content. If no element matches, Playwright's auto-wait applies and it will time out with an error. With Continue On Fail, an item with json.error and the sessionKey is returned instead. For XPath the selector is prefixed with 'xpath='.

Examples

Example 1: Read a product price after navigating to a page

Selector Type: CSS; CSS Selector: .price; Browser Endpoint: ws://playwright:3000; leave Session Open on, following a Navigate node.

Example 2: Extract a heading via XPath

Selector Type: XPath; XPath: //h1; Session ID set to the sessionKey from an earlier Playwright node.

Links

Discussion