From 3b4c6b52968ec1200d8a37493397356d9e29eadc Mon Sep 17 00:00:00 2001 From: empty Date: Sun, 28 Dec 2025 21:41:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20Tab=20=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=A3=80=E6=B5=8B=E5=92=8C=E7=B1=BB=E5=9E=8B=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改进: - Tab 类型识别: 添加 tabs-chrome, tabs-tab, ant-tabs-tab 等类名检测 - Tab 切换检测: 点击 tab 元素后显示 '📑 Tab 切换' 提示 - 内容刷新: Tab 切换后自动重新扫描内容区域 测试结果: - 通过率: 100% (2/2) - 登录: 全部 7 步骤成功 - 探索: 30 个元素, 4 个页面 --- src/agent/explorer.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/agent/explorer.py b/src/agent/explorer.py index 126027f..3aa141b 100644 --- a/src/agent/explorer.py +++ b/src/agent/explorer.py @@ -137,7 +137,11 @@ class FeatureExplorer: except: break else: - # 没有跳转,检查是否有新元素出现(如折叠菜单展开) + # 没有跳转,检查是否有新元素出现(如折叠菜单展开或 Tab 切换) + is_tab_click = element.get("type") == "tab" or \ + "tab" in element.get("tagName", "").lower() or \ + "tab" in element.get("name", "").lower() + new_elements = self._discover_elements() new_filtered = self._filter_and_sort(new_elements) @@ -146,7 +150,10 @@ class FeatureExplorer: new_items = [e for e in new_filtered if e.get("name") not in existing_names] if new_items: - print(f" 📋 发现 {len(new_items)} 个新元素(菜单展开)") + if is_tab_click: + print(f" 📑 Tab 切换,发现 {len(new_items)} 个新内容元素") + else: + print(f" 📋 发现 {len(new_items)} 个新元素(菜单展开)") # 将新元素插入到当前位置之后 elements = elements[:element_index] + new_items + elements[element_index:] @@ -218,10 +225,15 @@ class FeatureExplorer: // 推断类型 let type = 'link'; + const cls = el.className || ''; if (el.tagName === 'BUTTON' || el.getAttribute('role') === 'button') type = 'button'; if (el.closest('nav') || el.classList.contains('nav-item')) type = 'navigation'; if (el.getAttribute('role') === 'menuitem') type = 'menu'; - if (el.getAttribute('role') === 'tab') type = 'tab'; + if (el.getAttribute('role') === 'tab' || + cls.includes('tabs-chrome') || + cls.includes('tabs-tab') || + cls.includes('ant-tabs-tab') || + cls.includes('el-tabs__item')) type = 'tab'; elements.push({ name: text,