| name | browser-automation |
| description | browse the web, scrape data, and automate browser interactions using Stagehand and Browserbase. Use when asked to browse, search, scrape, or automate web tasks. |
Skill: Browser Automation (Stagehand)
Purpose
Automate web browsing tasks including navigating pages, extracting data, and interacting with elements (clicking, filling forms) using the Stagehand framework. This skill allows Droids to write and execute robust browser automation scripts.
When to use this skill
- You need to extract data from websites that don't have public APIs.
- You need to automate workflows like filling forms, logging into sites, or capturing screenshots.
- You need to research topics by browsing multiple pages deeply.
- The user asks to "browse", "scrape", "find X on website Y", or "automate Z".
Key Capabilities
- Navigate: Go to URLs and handle dynamic content.
- Extract: Turn unstructured web pages into structured JSON using AI.
- Observe: Identify interactive elements on the page.
- Act: Click, type, and interact with the page naturally.
Inputs
- Task description: What to achieve (e.g., "Find the pricing for X", "Login and download invoice").
- Target URL(s): Where to start.
- Data schema (optional): Structure of data to extract.
Conventions
- Framework: Use
Stagehand(@browserbasehq/stagehand). - Language: TypeScript/Node.js (preferred) or Python.
- Browser Engine: Browserbase (cloud) or local Chrome.
- Safety: Respect
robots.txtwhere appropriate. Do not automate actions on sites that strictly prohibit it in ToS unless for internal testing.
Required Behavior
- Setup: Ensure dependencies are installed (see
setup-guide.md). - Scripting: Write a self-contained script to perform the task.
- Execution: Run the script and capture the output.
- Refinement: If the script fails (e.g., selector not found), use Stagehand's AI capabilities to self-correct or refine the prompt.
Required Artifacts
- Automation Script: The code used to drive the browser (e.g.,
scrape_pricing.ts). - Output Data: JSON or text file containing the extracted info.
- Logs/Screenshots: Evidence of execution (if requested).
Implementation Checklist
- Verify environment variables (
BROWSERBASE_API_KEY,ANTHROPIC_API_KEYorOPENAI_API_KEY). - Initialize Stagehand config.
- Define the
act,extract, orobservesteps clearly. - Handle potential errors (timeouts, captchas).
- Save results to a local file.
For setup instructions, see setup-guide.md. For code examples, see examples.md.