Page combines deterministic browser controls with Stagehand’s natural-language act, observe, and extract methods. Navigation methods return the main-document Response, when the navigation produces one.
- TypeScript
- Python
- Go
Quick start
goto()
Navigate the page to a URL.string
The destination URL.
PageNavigationOptions
Promise<Response | null>
The final main-document response, or
null when no network response was produced.reload()
Reload the current page.PageReloadOptions
Promise<Response | null>
The final main-document response, or
null when no network response was produced.goBack()
Navigate backward in the page history.PageNavigationOptions
Promise<Response | null>
The final main-document response, or
null when no history navigation occurred or no network response was produced.goForward()
Navigate forward in the page history.PageNavigationOptions
Promise<Response | null>
The final main-document response, or
null when no history navigation occurred or no network response was produced.click()
Click at page coordinates.number
The horizontal page coordinate.
number
The vertical page coordinate.
PageClickOptions
Promise<void>
Resolves after the operation completes.
hover()
Move the pointer to page coordinates.number
The horizontal page coordinate.
number
The vertical page coordinate.
Promise<void>
Resolves after the operation completes.
scroll()
Scroll from page coordinates by the supplied deltas.number
The horizontal page coordinate.
number
The vertical page coordinate.
number
Horizontal scroll distance.
number
Vertical scroll distance.
Promise<void>
Resolves after the operation completes.
dragAndDrop()
Drag from one page coordinate to another.number
The drag origin’s horizontal coordinate.
number
The drag origin’s vertical coordinate.
number
The drop target’s horizontal coordinate.
number
The drop target’s vertical coordinate.
PageDragAndDropOptions
Options that configure this operation.
MouseButton
The mouse button to use:
"left", "middle", or "right".number
The input delay in milliseconds.
number
The number of intermediate pointer moves.
Promise<void>
Resolves after the operation completes.
type()
Type text at the current input target.string
The text to type.
PageTypeOptions
Promise<void>
Resolves after the operation completes.
keyPress()
Send a keyboard key press to the page.string
The keyboard key to send.
Promise<void>
Resolves after the operation completes.
evaluate()
Evaluate JavaScript in the page and return its result.string | ((arg: Arg) => R | Promise<R>)
JavaScript source or a function to evaluate.
Arg
An optional argument passed to the function.
Promise<R>
The operation result.
on()
Subscribe to console messages from this page and its page-owned sessions. Stagehand delivers each message using the underlying"Runtime.consoleAPICalled" event envelope.PageEventName
The console event name. Currently, the only supported value is
"console".PageEventListener
A callback that receives the event method, raw parameters, session ID, target ID,
and page ID. Async callbacks may overlap and are not awaited by later page calls.
Promise<CDPSubscription>
A subscription handle whose
unsubscribe() method stops delivery.CDPSubscription
unsubscribe(): Promise<void> removes the listener locally and from the Stagehand runtime.
Repeated calls share the completed cleanup. A failed runtime request can be retried by calling
unsubscribe() again.onToolsAdded()
Run a callback when WebMCP tools are added to this page or its child frames. The subscription reports future additions without replaying tools already registered. Usepage.tools() to
retrieve the current tools, or subscribe before navigation to receive tools from the new document.
Subscriptions remain active across navigation.ToolsAddedListener
A callback with the signature
(tools: WebMCPTool[]) => unknown. Each call receives
an array of added tools. Each tool exposes name, description, frameId, optional
inputSchema, annotations, and backendNodeId, and an invoke() method. See the
WebMCP reference for property types and invocation options.
Async callbacks may overlap and are not awaited by later page calls.Promise<CDPSubscription>
A subscription handle whose
unsubscribe() method stops delivery. See
CDPSubscription for cleanup behavior.frameId and name. A tool is also reported when its descriptor
changes; an identical descriptor is not reported again.onToolsRemoved()
Run a callback when WebMCP tools are removed from this page or its child frames. Removals include tools unregistered by the page and tools cleared when their document navigates or their frame detaches. The subscription reports future removals and remains active across navigation.ToolsRemovedListener
A callback with the signature
(tools: WebMCPToolIdentity[]) => unknown. Each call
receives an array of removed tool identities containing name and frameId, both
strings. These identities have no invoke() method. Async callbacks may overlap
and are not awaited by later page calls.Promise<CDPSubscription>
A subscription handle whose
unsubscribe() method stops delivery. See
CDPSubscription for cleanup behavior.addInitScript()
Run a script before other scripts whenever the page navigates.InitScriptSource<Arg>
A function, JavaScript source string, or object with exactly one of
path and content.Arg
An optional JSON-serializable argument. Valid only when
script is a function.Promise<void>
Resolves after the operation completes.
setExtraHTTPHeaders()
Set additional HTTP headers for this page.Record<string, string>
HTTP header names and values.
Promise<void>
Resolves after the operation completes.
setViewportSize()
Set the page viewport dimensions.number
Viewport width in CSS pixels.
number
Viewport height in CSS pixels.
Promise<void>
Resolves after the operation completes.
waitForLoadState()
Wait until the page reaches a load state.LoadState
The state to wait for:
"load", "domcontentloaded", or "networkidle".number
Maximum wait time in milliseconds.
Promise<void>
Resolves after the operation completes.
waitForTimeout()
Wait for a fixed number of milliseconds.number
The number of milliseconds to wait.
Promise<void>
Resolves after the operation completes.
waitForSelector()
Wait for a selector to reach the requested state.string
The selector to target.
PageWaitForSelectorOptions
Options that configure this operation.
boolean
Whether to traverse shadow roots. Closed roots require a navigated page; see the locator reference.
PageWaitForSelectorOptions['state']
The state to wait for:
"attached", "detached", "visible", or "hidden".number
Timeout in milliseconds, including frame readiness. Defaults to
30000; 0 disables the timeout.Promise<boolean>
The operation result.
screenshot()
Capture a screenshot of the page.ScreenshotOptions
Options that configure this operation.
ScreenshotOptions['animations']
How to handle active animations:
"disabled" or "allow".ScreenshotOptions['caret']
How to render the text caret:
"hide" or "initial".PageScreenshotClip
boolean
Whether to capture the full scrollable page. Cannot be combined with
clip.Locator[]
Page-created locators for elements to obscure. Every locator must belong to this page.
string
The CSS mask color.
boolean
Whether to use a transparent background.
string
A file path where the image is also written.
number
JPEG quality as an integer from 0 to 100. Valid only when
type is "jpeg".ScreenshotOptions['scale']
Whether to use
"css" or "device" pixel scale.string
CSS applied while taking the screenshot.
number
The non-negative operation timeout in milliseconds.
ScreenshotOptions['type']
The image format:
"png" or "jpeg".Promise<Uint8Array>
The screenshot image bytes.
pdf()
Render the current document to PDF with Chrome’s print pipeline.If a running print times out, further captures on that page fail until Chrome finishes the pending print. Other pages remain available.PDFOptions
Options that configure PDF rendering. Paper sizes and margins are measured in inches.
Whether to render the header and footer templates.
HTML for the print footer. Chrome fills elements with
pageNumber, totalPages, date,
title, and url classes.boolean
Whether to generate a document outline from the page structure. Defaults to
false.boolean
Whether to include document structure tags in the PDF. Defaults to
false.string
HTML for the print header, with the same supported classes as
footerTemplate.boolean
Whether to use landscape orientation.
PagePDFMargin
string
Page ranges to print, such as
"1-3, 5".number
The positive paper height in inches.
number
The positive paper width in inches.
string
A local file path where the PDF is also written. Node.js only.
boolean
Whether CSS
@page sizing takes precedence over width and height.boolean
Whether to include CSS backgrounds.
number
Render scale from
0.1 to 2.number
Maximum capture wait in milliseconds, including time queued behind another capture.
Defaults to
30000; 0 disables the deadline. Must be between 0 and 2147473647.Promise<Uint8Array>
The PDF bytes.
snapshot()
Capture the page’s accessibility-oriented DOM snapshot.PageSnapshotOptions
Promise<SnapshotResult>
tools()
Return the WebMCP tools registered on the page.WebMCPToolsOptions
Options that configure tool discovery.
number
Maximum time in milliseconds to wait for registered tools.
Promise<WebMCPTool[]>
The callable WebMCP tools registered on the page. See the
WebMCP reference.
url()
Return the page’s current URL.Promise<string>
The operation result.
title()
Return the page’s current document title.Promise<string>
The operation result.
close()
Close the page.Promise<void>
Resolves after the operation completes.
locator()
Create a locator for a CSS selector on this page.string
The selector to target.
Locator
The operation result.

