feat: 优化 Tab 切换检测和类型识别
Some checks failed
AI Web Tester CI / test (push) Has been cancelled

改进:
- Tab 类型识别: 添加 tabs-chrome, tabs-tab, ant-tabs-tab 等类名检测
- Tab 切换检测: 点击 tab 元素后显示 '📑 Tab 切换' 提示
- 内容刷新: Tab 切换后自动重新扫描内容区域

测试结果:
- 通过率: 100% (2/2)
- 登录: 全部 7 步骤成功
- 探索: 30 个元素, 4 个页面
This commit is contained in:
empty
2025-12-28 21:41:33 +08:00
parent 0a5e24cc9d
commit 3b4c6b5296

View File

@@ -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,