Skip to content

Commit a9b58f1

Browse files
[docs] rm stagehand.page from v3 snippets (#1271)
# why - migration guide docs for v3 still included references to `stagehand.page` which is not supported in v3 # what changed - replaced with `stagehand.context.pages()[0]` and `await stagehand.context.awaitActivePage()`
1 parent ffb5e5d commit a9b58f1

File tree

1 file changed

+9
-9
lines changed
  • packages/docs/v3/migrations

1 file changed

+9
-9
lines changed

packages/docs/v3/migrations/v2.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ await stagehand.init();
140140
const page = stagehand.context.pages()[0];
141141
await page.goto("https://example.com");
142142

143-
// Or use the convenience getter
144-
const page = stagehand.page;
143+
// Or `await` the active page
144+
const page = stagehand.context.awaitActivePage();
145145
await page.goto("https://example.com");
146146
```
147147

@@ -173,8 +173,8 @@ const newPage = await stagehand.context.newPage();
173173
// Set active page
174174
stagehand.context.setActivePage(newPage);
175175

176-
// Now stagehand.page returns newPage
177-
await stagehand.act("click button"); // Acts on newPage
176+
// implicitly takes action on newPage
177+
await stagehand.act("click button");
178178
```
179179

180180
### act() Method Changes
@@ -650,7 +650,7 @@ const result = await agent.execute("Complete the checkout process");
650650
v3 agents can now specify which page to operate on.
651651

652652
```typescript Stagehand v3 icon="/images/typescript.svg"
653-
const page1 = stagehand.page;
653+
const page1 = stagehand.context.pages()[0]
654654
const page2 = await stagehand.context.newPage();
655655

656656
const agent = stagehand.agent({
@@ -885,16 +885,16 @@ await stagehand.close();
885885

886886
### Error: Cannot find property 'page' on Stagehand instance
887887

888-
**Problem**: Direct `stagehand.page` access may not work immediately after init.
888+
**Problem**: Direct `stagehand.page` is not supported in Stagehand v3.
889889

890-
**Solution**: Use the Context API or ensure you're using the getter method:
890+
**Solution**: Use the Context API or `await` the active page:
891891

892892
```typescript
893893
// Use context API (recommended)
894894
const page = stagehand.context.pages()[0];
895895

896-
// Or use the convenience getter
897-
const page = stagehand.page;
896+
// Or grab the active page
897+
const page = await stagehand.context.awaitActivePage();
898898
```
899899

900900
### Error: act() method not found on page

0 commit comments

Comments
 (0)