开源官方发布自动监测

stagehand-python@4.2.0a0.dev1541: fix(extension): read text() from direct child text nodes ( 2728) ( 3052)

Fixed an XPath parsing bug in Stagehand where text() was incorrectly treated as . (reading full element.textContent ), causing silent locator mismatches and incorrect element clicks on pages containing shadow roots.

原始内容为英文;当前页面提供中文导航与来源说明,具体事实请以原文为准。

人类阅读

为什么值得关注

In Stagehand's composed-tree XPath parser, which activates whenever a page contains a shadow root, text() was previously evaluated using element.textContent , identical to . . This caused locator evaluations to diverge from native document.evaluate() when handling nested markup, leading to incorrect matches or silent zero-result queries (such as selecting the wrong element on .first().click() ). The fix updates packages/extension/dom/locatorScripts/xpathParser.ts to distinguish between direct child text nodes ( text() ) and the element's string-value ( . ). Specifically: - text() = 'v' is now evaluated existentially across direct child text nodes. - contains(text(), 'v') and normalize-space(text()) = 'v' collapse the node-set to the string-value of the first text node, consistent with XPath specifications. - . retains its previous behavior reading the element's full subtree string-value. - If existing locators relied on text() matching nested child text, they must be updated to use . instead.

Agent 解析

可执行摘要

Stagehand's composed-tree XPath parser ( xpathParser.ts ) now correctly evaluates text() against direct child text nodes instead of the entire subtree's element.textContent . This resolves behavioral divergence from native document.evaluate() on pages with shadow roots.

Agent 实用度
72/100
可信度
96%
机器格式
JSON + Markdown
下一步

开发者应核对什么

  • Review existing XPath locators in automated tests or agent workflows: if any locator relied on text() matching deeply nested subtree text, update it to use . instead.
分类

标签与路由

browserbasebrowser-agentautomation
相关信号

继续阅读