page.act() method allows you to control the browser using natural language instructions. The AI interprets your instruction, determines what actions to take, and executes them automatically.
Signature
instruction- Natural language description of what you want to do
Promise<ActResult>
How It Works
When you callpage.act():
- AI captures the current page state (DOM, visible elements, form fields, etc.)
- Your instruction is sent to the AI provider with page context
- AI determines which actions to perform (click, input, scroll, etc.)
- Actions are executed sequentially on the page
- Result is returned with details about what was done
Basic Examples
Simple Click Actions
Form Interactions
Intermediate Examples
Multi-Step Workflows
Conditional Actions
Navigation and Scrolling
Advanced Examples
Complex Interactions
Dynamic Content Handling
Search and Filter
Best Practices
Write Clear Instructions
Good:Break Down Complex Tasks
For very complex workflows, break them into steps:Handle Errors
Check the result and handle failures:Combine with Manual Automation
Mix AI actions with traditional automation for best results:Common Use Cases
Authentication Flows
Form Filling
Shopping and E-commerce
Content Navigation
Error Handling
TheActResult includes details about what happened:
Limitations
When AI actions fail, fall back to traditional selector-based automation.Performance Tips
- Use specific instructions - Reduces AI thinking time
- Combine actions - One instruction with multiple steps is faster than multiple calls
- Cache page state - If performing multiple actions on same page
- Use Haiku model - Faster for simple actions
Related
Data Extraction
Extract structured data with page.extract()
AI Setup
Configure AI agents and providers
Best Practices
Learn effective AI automation patterns
Page Interaction
Manual interaction methods (click, input)