Installation
The AI package is optional and must be installed separately:When to Use AI Automation
AI automation is ideal when:- Dynamic UIs: The page structure changes frequently or unpredictably
- Complex interactions: Multi-step workflows that are hard to script manually
- Data extraction: Extracting structured information from unstructured content
- Natural workflows: Actions that are easier to describe than to code
- Performance is critical: AI calls add latency and cost
- Exact control needed: You need pixel-perfect precision
- Stable selectors: The page structure is predictable and stable
- Offline automation: No internet connection or API access
Quick Example
Here’s how AI automation works:Key Features
Natural Language Actions
Thepage.act() method interprets your instruction and performs the necessary browser actions automatically:
Type-Safe Data Extraction
Thepage.extract() method extracts structured data from pages using AI, with optional Zod schema validation for type safety:
Supported Providers
- Anthropic - Claude models (fully supported)
- OpenAI - GPT models (coming soon)
How It Works
When you callpage.act() or page.extract():
- The AI agent captures a snapshot of the current page state
- Your instruction is sent to the AI provider along with page context
- The AI analyzes the page and determines what actions to take
- For
act(): Actions are executed automatically on the page - For
extract(): Data is extracted and validated against your schema
Next Steps
AI Setup
Configure AI agents with Anthropic or OpenAI
Natural Language Actions
Perform browser actions with natural language
Data Extraction
Extract structured data with type safety
Best Practices
Learn effective patterns for AI automation