AI Agent News/stories/stagehand-python-prerelease-resolves-locator-chains-across-iframes.md

Browsers

Stagehand Python prerelease resolves locator chains across iframes

Stagehand's Python package has a prerelease that lets locator chains move into iframe documents, so a query after an iframe selector searches inside that frame. A chain that ends at the iframe selector still returns the iframe element itself.

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

The change, released as stagehand-python@4.5.0a0.dev1736, adds a FrameChainResolver for queries that move between ordinary element scopes and iframe documents. Explicit frame hops require an iframe or frame target, and nested frames, including cross-origin frames running in a separate browser process, are covered.

Batched queries run within each document, and the resolver restores the original scope order before removing duplicate elements or applying nth. Resolution detects navigation, detachment and session changes so results from different documents are not mixed, and one deadline is shared across frame entry, readiness and queries.

The change's description says its tests cover CSS, XPath and text queries inside child documents, open and closed shadow roots, and cleanup of temporary objects across sessions. Public locator chaining is planned for a later pull request.

Why it matters if you build agents

Once public locator chaining ships, agent code should be able to target elements inside iframes, such as a checkout form, through a single chain.

For now this build only changes internal resolution, so code should not depend on the new behaviour yet.

Get stories like this every weekday

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

Subscribe