Conversation
- Add SEARCH_INDICATORS set to detect search-related elements by class/id - Add hasFormControlDescendant helper to detect form controls within wrapper elements - Add isSearchElement function to identify search buttons/inputs - Enhance isInteractive to detect: - Labels wrapping form controls (label > span > input pattern) - Span elements containing form controls - Search-related elements This improves detection of UI patterns where clickable elements are wrapped in non-standard containers like labels and spans. Ref: browser-use ClickableElementDetector research
- Add AXTreeNode interface and fetchInteractiveNodeIds method to CDPBridge - Add fetchEventListeners method to detect click-related event listeners via DOMDebugger - Add detectListeners and useAXTree options to SnapshotOptions - Add annotateWithListeners to mark elements with click listeners in snapshot This enables more accurate interactivity detection by leveraging Chrome DevTools Protocol to identify elements that have event listeners attached, beyond what can be detected from static HTML attributes alone. Ref: browser-use ClickableElementDetector research
- Add tests for SEARCH_INDICATORS set in generateSnapshotJs - Add tests for hasFormControlDescendant function - Add tests for isSearchElement function - Add tests for label/span wrapper detection in isInteractive - Add tests for fetchInteractiveNodeIds (AXTree parsing) - Add tests for fetchEventListeners (DOM listener extraction) Total: 254 tests passing
904b8bd to
9401151
Compare
Owner
Author
|
我已经直接把这版 PR 收到一个更稳的范围。 深度 review 结论:
我已经直接在当前分支处理:
这是更简洁也更稳的方案:先把已验证有效的 heuristics 合进去;如果后面要做 listener-aware snapshot,应该单独起 PR,先重设数据流(例如在页面内先做 annotation,再统一交给 本地验证已过:
follow-up commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改进概述
基于 browser-use 的
ClickableElementDetector研究,增强了 DOM 元素检测能力。改动内容
1. 搜索元素启发式检测 (
dom-snapshot.ts)SEARCH_INDICATORS集合,识别 class/id 中的搜索相关关键词isSearchElement()函数,检测搜索按钮/输入框label > span > input模式)2. CDP 事件监听器检测 (
cdp.ts)AXTreeNode接口和fetchInteractiveNodeIds()方法fetchEventListeners()方法,通过 DOMDebugger 获取事件监听器detectListeners和useAXTree选项到SnapshotOptionsannotateWithListeners()后处理函数3. 类型定义更新 (
types.ts)SnapshotOptions接口,添加detectListeners和useAXTree选项4. 测试覆盖
效果