Stagehand Page
All Page methods available when using the Stagehand driver.
Access via runtime.page after launching a Stagehand runtime.
How these methods work over HTTP
Every method below is a remote call. The SDK translates it into a structured step sent to a single endpoint:
The call field maps directly to the method name. args is a JSON array of the method’s arguments. You can batch multiple steps in one request.
Navigation
goto(url, options?)
Navigate the page to a URL.
Options include:
- waitUntil: ‘load’ | ‘domcontentloaded’ | ‘networkidle’
- timeoutMs: Maximum navigation time in milliseconds
Returns RemoteStagehandResponse \| null
reload(options?)
Reload the current page.
Options include:
- waitUntil: ‘load’ | ‘domcontentloaded’ | ‘networkidle’
- timeoutMs: Maximum reload time in milliseconds
- ignoreCache: Whether to bypass the browser cache
Returns RemoteStagehandResponse \| null
goBack(options?)
Navigate to the previous page in history.
Returns null if there is no previous page.
Returns RemoteStagehandResponse \| null
goForward(options?)
Navigate to the next page in history.
Returns null if there is no next page.
Returns RemoteStagehandResponse \| null
waitForLoadState(state?, options?)
Wait for the page to reach a specific load state.
States:
- ‘load’: Wait for the load event
- ‘domcontentloaded’: Wait for DOMContentLoaded event
- ‘networkidle’: Wait until no network connections for 500ms
Page Info
url()
Get the current URL of the page.
This is a synchronous method that returns the current URL.
Returns string
title()
Get the title of the page.
Returns string
setViewportSize(width, height, options?)
Set the viewport size of the page.
Actions
click(x, y, options?)
Click at the specified coordinates.
Options include:
- button: ‘left’ | ‘right’ | ‘middle’ (default: ‘left’)
- clickCount: Number of clicks (default: 1, use 2 for double-click)
- returnXpath: If true, returns the XPath of the clicked element
Returns string \| void
hover(x, y, options?)
Hover at the specified coordinates.
If returnXpath is true, returns the XPath of the hovered element.
Returns string \| void
scroll(x, y, deltaX, deltaY)
Scroll at the specified position by the given delta.
Positive deltaY scrolls down, negative scrolls up.
dragAndDrop(fromX, fromY, toX, toY, options?)
Drag from one point to another.
If returnXpath is true, returns [fromXpath, toXpath] of the dragged elements.
Returns [string, string] \| void
type(text, options?)
Type text into the currently focused element.
The delay option adds a pause between keystrokes for realistic typing.
Queries
locator(selector)
Create a locator for an element using a CSS or XPath selector.
Locators support automatic shadow DOM traversal.
Returns RemoteStagehandLocator
deepLocator(selector)
Create a deep locator that can traverse iframes and shadow roots.
Deep locators use hop notation to navigate through iframes:
- Use >>> to hop into an iframe
- Example: “#outer-frame >>> #inner-frame >>> button”
Returns RemoteStagehandLocator
Waiting
waitForSelector(selector, options?)
Wait for an element matching the selector to appear.
Options include:
- state: ‘visible’ | ‘hidden’ | ‘attached’ | ‘detached’
- timeout: Maximum wait time in milliseconds
- pierceShadow: Whether to pierce shadow DOM (default: true)
Screenshots & PDF
screenshot(options?)
Capture a screenshot of the page.
Options include:
- path: File path to save the screenshot
- fullPage: Capture the full scrollable page
- type: ‘png’ | ‘jpeg’
- quality: JPEG quality (0-100)
- clip: Specific region to capture
Returns Buffer
snapshot(options?)
Get a snapshot of the page DOM.
Returns a structured representation of the page content.
Returns StagehandSnapshotResult
Evaluation
evaluate(pageFunction, arg?)
Execute JavaScript code within the page context.
The return value must be JSON-serializable.
Returns R
Other
addInitScript(script, arg?)
Add an initialization script that runs before page scripts.
The script runs on every navigation.

