Skip to content

Commit 2102ad0

Browse files
authored
Fix stagehand example code (#25392)
1 parent 0853068 commit 2102ad0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/content/docs/browser-rendering/platform/stagehand.mdx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,26 @@ Then, in your worker code, import the `workersAIClient.ts` file and use it to co
115115
await stagehand.init();
116116
const page = stagehand.page;
117117

118-
await page.goto('https://www.themoviedb.org/');
119-
// for multi-step actions, use observe
120-
const actions = await page.observe('Search for "The Iron Giant" and click the Search button');
118+
await page.goto('https://demo.playwright.dev/movies');
119+
120+
// if search is a multi-step action, stagehand will return an array of actions it needs to act on
121+
const actions = await page.observe('Search for "Furiosa"');
121122
for (const action of actions)
122123
await page.act(action);
123-
await page.act('Click the first search result');
124+
125+
await page.act('Click the search result');
126+
127+
// normal playwright functions work as expected
128+
await page.waitForSelector('.info-wrapper .cast');
129+
124130
let movieInfo = await page.extract({
125131
instruction: 'Extract movie information',
126132
schema: z.object({
127133
title: z.string(),
128134
year: z.number(),
129-
director: z.string(),
135+
rating: z.number(),
136+
genres: z.array(z.string()),
137+
duration: z.number().describe("Duration in minutes"),
130138
}),
131139
});
132140

0 commit comments

Comments
 (0)