Act
Perform actions on the current page.
act()
allows Stagehand to interact with a web page. Provide an action
like "Click on the add to cart button"
, or "Type 'Browserbase' into the search bar"
.
Small atomic goals perform the best. Avoid using act()
to perform complex actions.
You can pass an ObserveResult
to act()
to perform the suggested action, which will yield a faster and cheaper result (no LLM inference).
Arguments: ActOptions
| ObserveResult
ActOptions
:
Describes the action to perform
Specifies the model to use
Configuration options for the model client
Determines if vision-based processing should be used. Defaults to “fallback”
Variables to use in the action. Variables in the action string are referenced using %variable_name%
Timeout in milliseconds for waiting for the DOM to settle
ObserveResult
:
A string representing the element selector
A string describing the possible action
The method to call on the element
The arguments to pass to the method
Returns: Promise<ActResult>
If the action was completed successfully
Details about the action’s execution
The action performed