Skip to main content
Web applications often open a new tab when someone clicks a button or link, and a script that only watches the original tab breaks when the content lands elsewhere. Stagehand follows the new tab for you.

The Stagehand page

The active page is whichever tab Chrome has focused in its last-focused window, so a tab the browser opens and activates becomes the target on its own. act(), observe(), and extract() all default to that page. The usual patterns keep working:
Important: The page object you captured before the click still refers to the original tab. Re-read the active page, or hold an explicit reference to each tab, when you need to reach back to it.

Manual page management

For more control or multitab workflows, you can manage multiple tabs explicitly. Set the active page when you want the default target to follow you:
Locators belong to the page they were created on. page.locator(selector) carries that page’s identity, so a locator from one tab never resolves against another.

Next steps

Act

Target a specific tab with the page option on any primitive.

Working with iframes

Stagehand traverses iframes automatically. Scope with a selector when you need to narrow the snapshot.

Browser configuration

Manage browser contexts and sessions for complex automation scenarios.

Logging & debugging

Set log levels and read structured records while you debug.