Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/content/docs/browser-rendering/platform/stagehand.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,26 @@ Then, in your worker code, import the `workersAIClient.ts` file and use it to co
await stagehand.init();
const page = stagehand.page;

await page.goto('https://www.themoviedb.org/');
// for multi-step actions, use observe
const actions = await page.observe('Search for "The Iron Giant" and click the Search button');
await page.goto('https://demo.playwright.dev/movies');

// if search is a multi-step action, stagehand will return an array of actions it needs to act on
const actions = await page.observe('Search for "Furiosa"');
for (const action of actions)
await page.act(action);
await page.act('Click the first search result');

await page.act('Click the search result');

// normal playwright functions work as expected
await page.waitForSelector('.info-wrapper .cast');

let movieInfo = await page.extract({
instruction: 'Extract movie information',
schema: z.object({
title: z.string(),
year: z.number(),
director: z.string(),
rating: z.number(),
genres: z.array(z.string()),
duration: z.number().describe("Duration in minutes"),
}),
});

Expand Down