December 3, 2026
Introducing Stagehand 4.5: getByRole(), locator chaining, page.onResponse(), and more

We're excited to announce Stagehand 4.5! This release makes it easier to listen for important browser events, improves syntax & type-checking for working with locators, and (of course) bug fixes.
Here are the highlights:
getByRole() and getByText()
page.getByRole(role, { name }) matches elements by the role and accessible name Chromium computes for its accessibility tree. page.getByText(text) matches the smallest elements whose text contains the string. Both return a lazy Locator: nothing is queried until you call an action like click() or a read like count(). role is typed as AriaRole, so a misspelled role is a compile error.
Options are in the docs.
Locator chaining
Calling locator(), getByRole(), or getByText() on a locator now searches inside its matches. If a match is an iframe, the next query runs in that iframe's document. Before 4.5, reaching an element inside a container took one selector for the whole path:
In 4.5 you can chain from the container:
Chained locators can also be passed to act(), observe(), and extract() as scopes and exclusions, and to screenshot() as masks (#3539).
page.onResponse()
page.onResponse(listener) invokes listener with a Response for each network response from the page and its child frames, including fetch and XHR. It fires when the status and headers arrive; body methods like json() and text() wait for the body to finish loading. It does not replay earlier responses, it stays active across navigations, and it returns a subscription whose unsubscribe() stops it.
Read the docs.
page.onConsole()
page.onConsole(listener) invokes listener for each console call on the page with the raw CDP Runtime.consoleAPICalled event: method, params, sessionId, targetId, and pageId. params.type is the console method, such as log or error, and params.args holds the arguments as CDP RemoteObjects. params is typed as generic JSON, so cast it to the fields you read. It returns the same subscription handle as onResponse(). page.on("console", listener) still works and is deprecated (#3490).
Community contributions
Thanks to the contributors outside Browserbase whose fixes shipped in this release and in the browse CLI:
- @aryansahai22:
headerValue(),headerValues(), andheadersArray()no longer report a header with an empty value as missing on HTTP/2 responses (#3422). - @Kelvin-Waititu:
context.cookies(url)no longer returns host-only cookies for subdomains of the cookie's host (#3465). - @harjothkhara:
browseno longer prints replacement characters when a daemon reply splits a multi-byte UTF-8 character across socket chunks (#3463, browse 0.12.0). - @kenneshagarg:
browse doctornow fails and shows the cause when the session's last browser start failed (#3423, browse 0.11.4).
Also new in the browse CLI 0.12.0: browse cloud sessions create --size regular|large|xlarge (#3482), browse cloud search filters such as --include-domains, --category, and --max-age-hours (#3481), and browse discord (#3450). browse cloud contexts update was removed (#3499).
Other fixes
waitForLoadState("networkidle")no longer times out on a page that is already idle, and it counts requests already in flight (#3503).- Network tracking no longer misses requests made immediately by newly attached cross-origin iframes (#3454).
- Selectors with many matches resolve with fewer browser round trips (#3533).
- Locator calls no longer time out on pages that were already open when the extension loaded into a running browser (#3501).
Give it a try and tell us what you build!