提交 1860c218 authored 作者: 陈泽健's avatar 陈泽健

fix(smart-locate): 修复抽屉内元素定位问题

1. 点击功能中心后等待抽屉打开
2. 资产管理/资产信息等菜单优先在抽屉内查找
3. 使用 .el-drawer >> text="xxx" 选择器匹配抽屉内元素
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
上级 ca76670a
......@@ -319,7 +319,38 @@ class SmartLocateService:
page = self.executor._page
# ⚠️ 新增:检查是否需要在抽屉内查找
drawer_keywords = ['资产管理', '资产信息', '资产故障', '资产设备',
'会议预约', '会议运维', '会议转录', '信息发布',
'数据统计', '运维维护', '维护工单', '会务管理',
'信息管理', '集控控制', '预定']
in_drawer = any(kw in name for kw in drawer_keywords)
# 第一级:关键词直接匹配
if in_drawer:
# ⚠️ 优先在抽屉内查找
logger.debug(f"检测到抽屉内元素,优先在 .el-drawer 内查找")
element, selectors = match_element_by_keywords(page, keywords, action)
if not element:
# 尝试直接用文本匹配抽屉内的元素
for kw in keywords:
if len(kw) >= 2:
try:
drawer_selector = f'.el-drawer >> text="{kw}"'
page.wait_for_selector(drawer_selector, timeout=2000)
element = page.locator(drawer_selector).first
selectors = [{
'type': 'css',
'value': drawer_selector,
'confidence': 0.90,
'priority': 1
}]
logger.info(f"在抽屉内找到元素: {drawer_selector}")
break
except Exception:
continue
else:
element, selectors = match_element_by_keywords(page, keywords, action)
if element and selectors:
......@@ -415,6 +446,16 @@ class SmartLocateService:
# 等待可能的页面变化
page.wait_for_timeout(1000)
# ⚠️ 新增:如果是点击功能中心,等待抽屉打开
if '功能中心' in result.get('name', ''):
logger.debug("检测到功能中心点击,等待抽屉打开...")
try:
page.wait_for_selector('.el-drawer', timeout=5000)
page.wait_for_timeout(500) # 额外等待动画
logger.debug("功能中心抽屉已打开")
except Exception as e:
logger.warning(f"等待抽屉打开失败: {e}")
elif action == 'wait':
timeout = params.get('timeout', 10000)
page.wait_for_selector(selector, timeout=timeout)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论