AI Agent News/stories/stagehand-python-prerelease-scopes-locator-chains-to-each-element.md

Browsers

Stagehand Python prerelease scopes locator chains to each element

Browserbase's stagehand-python 4.5.0a0.dev1735 prerelease changes how chained locators are resolved, so an nth index applies where it appears in the chain. Intermediate matches now stay inside the browser, and only the requested count or element IDs are returned to the caller.

Source: github.com/browserbase/stagehand/releases/tag/stagehand-python%404.5.0a0.dev1735

Browserbase tagged the stagehand-python@4.5.0a0.dev1735 prerelease on 23 November with a change to locator chains. A query such as .card -> nth(1) -> button now searches only inside the second card, while .card -> button -> nth(1) selects the second button across all cards. A new FrameElementChainResolver supports count, selected and all-target modes.

Queries stay within their element scopes, including open and closed shadow roots, and existing CSS, XPath and text matching is preserved. Duplicate elements are removed before indexing. Frame entry is rejected, so cross-frame transitions remain with the existing cross-frame resolver.

Temporary browser handles are released once the needed backend node IDs have been captured. A single deadline covers readiness, resolution and cleanup, including failures, cancellation and responses that arrive after a timeout.

Why it matters if you build agents

Agent code that chains nth() after a scoping selector may now match different elements than it did before, so selectors that depend on index position should be rechecked. Counting or selecting one element no longer pulls every intermediate match into the client, which can make large pages cheaper to query. Because this is a development prerelease, pin the exact version before relying on it.

Get stories like this every weekday

One short email with the day's agent tooling news.

Subscribe