Use Stagehand act, extract, and observe primitives for precise step-controlled browser automation
domain: docs.stagehand.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Install the SDK: npm install @browserbasehq/stagehand (TypeScript) or pip install stagehand (Python)
Instantiate Stagehand with your LLM provider config (e.g. modelName: 'claude-opus-4-5', apiKey) and call stagehand.init()
Use await stagehand.page.act({ action: 'click the login button' }) to perform a natural-language action
Use await stagehand.page.extract({ instruction: 'extract the product price', schema: z.object({ price: z.string() }) }) to pull typed data from the page
Use await stagehand.page.observe({ instruction: 'find all clickable navigation links' }) to discover available actions before acting
Close with await stagehand.close() to release the underlying browser session
Known gotchas
Each act/extract/observe call makes one or more LLM API calls; run observe first to confirm an element exists before act to avoid wasted retries
Stagehand uses the page accessibility tree plus DOM for element location; pages with very low-contrast or purely visual UIs may require screenshot-mode fallback
When using the Browserbase backend, session timeouts default to 60 seconds of inactivity; send periodic heartbeats or set a longer timeout at session creation
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?