Overview
The Actor API provides direct access to Chrome DevTools Protocol (CDP) for precise, deterministic browser control. While the Agent uses LLMs for autonomous navigation, the Actor API lets you write explicit automation scripts with full control over browser actions.Actor API is a Playwright-like library built on CDP. Use it for deterministic automation where you need precise control over every browser action.
Key Concepts
- Page: Represents a browser tab or iframe
- Element: A DOM element with interaction methods
- Mouse: Mouse control for clicks, drags, and movements
- Utils: Helper methods for common operations
Quick Start
Page API
ThePage class provides tab-level operations.
Navigation
Screenshots
JavaScript Execution
Keyboard Input
Viewport
Element Finding
Content Extraction
browser_use/actor/page.py:491-554.
Element API
TheElement class represents a DOM element with interaction methods.
Clicking
Text Input
fill method:
- Focuses the element
- Clears existing text (if
clear=True) - Types character-by-character with human-like delays
- Handles special characters and modifiers
browser_use/actor/element.py:353-507.
Hover
Focus
Select Options
Drag and Drop
Properties
Element Screenshots
JavaScript Evaluation on Element
Mouse API
Low-level mouse control.Using Actor in Tools
Combine Actor API with Agent tools for hybrid automation:When using Actor API in tools, the parameter must be named
browser_session: BrowserSession, not browser: Browser.Real-World Examples
Form Filling
Data Extraction
File Upload
Infinite Scroll
Shadow DOM
Best Practices
1. Element Detection with AI
2. Error Handling
3. Waiting for Actions
4. Structured Extraction
CDP Access
For advanced use cases, access raw CDP:See Also
- Tools API - Custom agent actions
- Browser Configuration - Browser setup
- Agent API - High-level AI automation