import { CodeBlock } from "@/components/code-block"; export default function Selectors() { return (

Selectors

Refs (recommended)

Refs provide deterministic element selection from snapshots. Best for AI agents.

Why refs?

  • Deterministic - Ref points to exact element from snapshot
  • Fast - No DOM re-query needed
  • AI-friendly - LLMs can reliably parse and use refs

CSS selectors

button" agent-browser click "[data-testid='submit']"`} />

Text & XPath

Semantic locators

Find elements by role, label, or other semantic properties:

); }