October 12, 2026
WebMCP hooks, PDF exports, and more in Stagehand 4.2
We're excited to announce Stagehand 4.2!
In this release, we've focused on helping browser agents update WebMCP tools as pages change, export documents programmatically, and give developers more control over how long browser operations run.
Here are the highlights:
- WebMCP tools that change with the page — subscribe to
page.onToolsAdded()andpage.onToolsRemoved()to react as websites expose new actions or update their forms. Useful for checkout flows where available inputs and actions change throughout the session. - Native PDF exports — export browser pages as PDFs, with configurable print settings. Save invoices, reports, and other documents directly from your browser workflow.
- Timeouts for locator operations and snapshots — configure
{ timeout }onlocator.click(),fill(), other locator operations, andpage.snapshot(). Defaults to 20 seconds; usetimeout: 0to disable it. - More reliable iframe and shadow DOM interactions — iframe-crossing
page.locator()calls wait for the frame to be ready,page.snapshot({ includeIframes: true })produces correct element references across frames, and XPathtext()selectors correctly match direct text on pages with shadow DOM.
Give it a try and tell us what you build!