Documentation Index
Fetch the complete documentation index at: https://mintlify.com/browserbase/stagehand/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheV3Context class manages the Chrome DevTools Protocol (CDP) connection and orchestrates page lifecycle. It maintains one Page instance per top-level browser tab and handles iframe (OOPIF) sessions.
Accessing Context
Access the context through thestagehand.context property:
Methods
newPage()
Create a new browser tab and return its Page object.Optional URL to navigate toDefault:
"about:blank"A Page object for the new tab
activePage()
Get the most recently active page.The active page, or undefined if no pages exist
setActivePage()
Explicitly set which page is considered active.The page to make active
pages()
Get all top-level pages (tabs) in creation order.Array of all Page objects
addInitScript()
Add a script that runs on every new document before other scripts.Script source, function, or file path
Optional argument passed to the script
setExtraHTTPHeaders()
Set custom HTTP headers for all requests.Headers to include in all requests
cookies()
Get browser cookies, optionally filtered by URL.Optional URL(s) to filter cookies
Array of cookie objects
addCookies()
Add one or more cookies to the browser.Array of cookies to add
clearCookies()
Clear cookies from the browser.Optional filters to selectively clear cookies