observe() is used to get a list of actions that can be taken on the current page. It’s useful for adding context to your planning step, or if you unsure of what page you’re on.

  const observations = await page.observe();

observe() returns an array of objects, each with an XPath selector and short description.

If you are looking for a specific element, you can also pass in an instruction to observe via: observe({ instruction: "your instruction"}).

  const [{ selector, description }] = await page.observe({
    instruction: "Find the buttons on this page",
  });

observe() currently only evaluates the first chunk in the page.

Arguments: ObserveOptions

instruction
string

Provides instructions for the observation. Defaults to “Find actions that can be performed on this page.”

modelName
AvailableModel

Specifies the model to use

modelClientOptions
object

Configuration options for the model client

useVision
boolean | 'fallback'

Determines if vision-based processing should be used. Defaults to “fallback”

domSettleTimeoutMs
number

Timeout in milliseconds for waiting for the DOM to settle

Returns: Promise<ObserveResult[]>

Each ObserveResult object contains a selector and description.

selector
string
required

A string representing the element selector

description
string
required

A string describing the possible action