Overview
Theact() method performs actions on the page using natural language instructions. It uses AI to understand your intent and execute the appropriate interactions.
Syntax
Parameters
Instruction-based
Natural language description of the action to performExamples:
"click the login button""fill in the email field with [email protected]""select 'California' from the state dropdown"
Action-based (from observe)
Action object returned from
observe()Options
Returns
Result of the action
Examples
Basic Actions
Using Variables
Using with observe()
Custom Model
With Timeout
Multi-page Workflow
Common Actions
Clicking
Typing
Form Interactions
Navigation
Error Handling
Best Practices
-
Be specific: Use clear, descriptive instructions
- Good:
"click the blue 'Sign Up' button in the header" - Bad:
"click button"
- Good:
-
Use variables for sensitive data: Avoid hardcoding credentials
-
Handle results: Always check
result.success -
Add timeouts for critical operations:
-
Combine with observe(): Find elements first for more reliable actions