Skip to main content
The 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

Parameters:
  • instruction - Natural language description of what you want to do
Returns: Promise<ActResult>

How It Works

When you call page.act():
  1. AI captures the current page state (DOM, visible elements, form fields, etc.)
  2. Your instruction is sent to the AI provider with page context
  3. AI determines which actions to perform (click, input, scroll, etc.)
  4. Actions are executed sequentially on the page
  5. Result is returned with details about what was done

Basic Examples

Simple Click Actions

Form Interactions

Intermediate Examples

Multi-Step Workflows

Conditional Actions

Advanced Examples

Complex Interactions

Dynamic Content Handling

Search and Filter

Best Practices

Write Clear Instructions

Be specific and descriptive. Instead of “click the button”, say “click the blue submit button at the bottom of the form”
Good:
Bad:

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

The ActResult includes details about what happened:

Limitations

AI actions are powerful but have limitations:
  • Require API calls (adds latency and cost)
  • May not work on heavily obfuscated UIs
  • Success rate varies by page complexity
  • Not suitable for precise pixel-level interactions
When AI actions fail, fall back to traditional selector-based automation.

Performance Tips

  1. Use specific instructions - Reduces AI thinking time
  2. Combine actions - One instruction with multiple steps is faster than multiple calls
  3. Cache page state - If performing multiple actions on same page
  4. Use Haiku model - Faster for simple actions

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)