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,