Skip to main content

🧪 Testing

Stagehand

Stagehand is an open-source browser automation framework from Browserbase that sits on top of Playwright and lets you drive a real browser with plain English instructions. Instead of writing brittle CSS selectors, you tell it what to do and it figures out the clicks, typing and waiting for you, which makes web automation much faster to write and far more resilient to changes.

Quick Facts

Developer Browserbase
First released 2024
Latest version See official website
Language TypeScript (Node.js) and Python
Platforms Runs anywhere Playwright runs
License MIT (open source)
Pricing Free and open source; optional paid cloud browser services

What is Stagehand?

Stagehand is a browser automation framework created by Browserbase, the company behind cloud browser infrastructure. It wraps Playwright, the popular open-source browser automation library, and adds an AI layer on top, so instead of writing selectors and step-by-step instructions you describe what you want in natural language.

The core idea is that automation should target intent, not the internals of a page. When a website changes its buttons, class names or layout, a traditional test or scraper often breaks, while a Stagehand script that says 'click the checkout button' keeps working. That makes it a practical middle ground between fully scripted tools like Playwright and fully autonomous agents.

Stagehand went open source in late 2024 and quickly became popular with developers building web scrapers, QA automation and agentic workflows. Because it is built on Playwright, you keep access to the whole Playwright toolkit for screenshots, tracing, waiting and multi-tab control whenever you need deterministic behavior.

Key Features

  • Act API: perform natural-language actions such as clicking, typing, scrolling and navigation
  • Extract API: pull structured JSON data out of a page using a schema you define
  • Observe API: ask the model which interactive elements exist before you decide what to do
  • Built directly on Playwright, so screenshots, tracing and headless mode all still work
  • Pluggable AI clients, including OpenAI, Anthropic and other providers
  • Available in both TypeScript and Python
  • Agentic loops supported, where the script plans multiple steps and reacts to what it finds

How to get started

Start by installing the package with npm or pip, then set up an API key for the language model you want to use. The framework needs an LLM to interpret your instructions, so you bring your own key and pay whatever that model costs.

Your first script can be tiny: launch a browser, navigate to a site, use the act API to click something, and use the extract API to read data back into a variable. The official docs have quick-start guides for both TypeScript and Python.

  • Install Stagehand via npm or pip
  • Set an LLM API key in your environment
  • Launch a browser and navigate to a page
  • Use act() to click and fill, and extract() to read structured data
  • Work through the quick-start examples at docs.stagehand.dev

Use cases

  • Web scraping and data collection at scale
  • End-to-end testing of web applications with natural-language assertions
  • Form filling and data entry automation
  • Monitoring dashboards and alerting when content changes
  • Building agentic workflows that browse the web on behalf of users
  • Automating repetitive tasks like booking, ordering and research

Pricing and licensing

Stagehand itself is free and open source under the MIT license, so you can use it in commercial projects and self-host everything. The only ongoing cost is the language model usage behind the natural-language actions, which is billed by whatever AI provider you connect.

Browserbase also offers a managed cloud browser platform that works well with Stagehand for large-scale parallel automation, but it is optional. You can run Stagehand locally with your own Playwright browser installation for free.

Pros and cons

The big win is developer speed. Scripts that would take hours with traditional selectors can be written in minutes, and they survive frontend changes far better than brittle XPath or CSS selectors. Because it is built on Playwright, you are not locked into a toy framework, and the open-source license keeps it accessible.

The trade-offs are cost, latency and determinism. Every action involves a language model call, which costs money and adds delay, and AI-driven actions are inherently less deterministic than hard-coded ones, so critical flows may still need explicit Playwright steps. It is also a young project with a smaller community than the tools it builds on.

Alternatives

  • Playwright: the underlying framework, for fully deterministic scripted automation
  • Puppeteer: Chrome-first automation library from the Chrome team
  • Selenium: long-established automation tool with broad language support
  • Skyvern: open-source AI agent for browser-based workflows
  • Browserbase: managed cloud browser infrastructure for running automation at scale

Resources

What is New?

By continuing to use the site, you agree to the use of cookies.