// Basic usage
 await page.act({ action: "click on add to cart" });

 // Using variables
 await page.act({
   action: "enter %username% into the username field",
   variables: {
     username: "john.doe@example.com",
   },
 });

 // Multiple variables
 await page.act({
   action: "fill in the form with %username% and %password%",
   variables: {
     username: "john.doe",
     password: "secretpass123",
   },
 });

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.

Arguments: ActOptions

action
string
required

Describes the action to perform

modelName
AvailableModel

Specifies the model to use

modelClientOptions
object

Configuration options for the model client

useVision
boolean | 'fallback'

Determines if vision-based processing should be used. Defaults to “fallback”

variables
Record<string, string>

Variables to use in the action. Variables in the action string are referenced using %variable_name%

domSettleTimeoutMs
number

Timeout in milliseconds for waiting for the DOM to settle

Returns: Promise<ActResult>

success
boolean
required

If the action was completed successfully

message
string
required

Details about the action’s execution

action
string
required

The action performed