Skip to main content

Executing actions

Stagehand has an act() function that can be used to execute actions on a page using natural language. Here’s an example of Stagehand to find jobs on LinkedIn: Take actions with Stagehand This workflow is as simple as the following lines of code:
The page object extends the Playwright page object, so you can use any of the Playwright page methods with it.

Get structured data from the page

You can use extract() to get structured data from the page. Here’s an example of how to extract the job title from the job posting:
Stagehand uses Zod for TypeScript and Pydantic for Python to help you define the schema of the data to be extracted.

Preview/Cache an action

Sometimes you want to preview an action before it’s executed. You can do this by calling page.observe() before act().
action will be a JSON object that describes the action to be taken.
For more on caching, see the caching docs.

What actions can I take?

Stagehand maps natural language to Playwright actions. We generally support the following actions: Each of these actions can be triggered using natural language commands. For example: