Files
ai-web-tester/debug_page.py
empty 1f1cc4db9a
Some checks failed
AI Web Tester CI / test (push) Has been cancelled
feat: 增强测试框架功能
主要改进:
- 新增统一测试器 (universal_tester.py) 支持多种测试模式
- 优化测试报告生成器,支持汇总报告和操作截图
- 增强探索器 DFS 算法和状态指纹识别
- 新增智能测试配置 (smart_test.yaml)
- 改进 AI 模型集成 (GLM/Gemini 支持)
- 添加开发调试工具和文档
2026-01-05 20:23:02 +08:00

83 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
调试页面元素
"""
import sys
sys.path.insert(0, ".")
from src import WebTester
def debug_page():
"""调试页面元素"""
tester = WebTester(model="glm", headless=False)
try:
# 启动浏览器
tester.start()
tester.goto("http://47.99.105.253:8084")
# 登录
print("登录中...")
tester.test("填入账号admin 密码password登录成功")
# 等待页面加载
import time
time.sleep(3)
page = tester.browser.page
# 检查侧边栏
print("\n=== 检查侧边栏元素 ===")
# 查找所有侧边栏元素
sidebar_selectors = [
".ant-layout-sider",
"aside",
".sidebar",
".ant-menu"
]
for sel in sidebar_selectors:
count = page.locator(sel).count()
print(f"{sel}: {count} 个元素")
# 查找菜单项
print("\n=== 查找菜单项 ===")
menu_texts = ["立项论证管理", "产品方案管理", "研制方案", "系统管理"]
for text in menu_texts:
# 尝试不同的定位器
locators = [
f"text={text}",
f".ant-menu-item:has-text('{text}')",
f"aside :has-text('{text}')",
f"*:has-text('{text}')"
]
print(f"\n查找: {text}")
for loc_str in locators:
try:
loc = page.locator(loc_str)
count = loc.count()
visible = 0
for i in range(count):
if loc.nth(i).is_visible():
visible += 1
print(f" {loc_str}: {count} 个元素, {visible} 个可见")
except Exception as e:
print(f" {loc_str}: 错误 - {e}")
# 打印页面结构
print("\n=== 页面结构 ===")
print(f"当前URL: {page.url}")
print(f"页面标题: {page.title()}")
finally:
tester.stop()
if __name__ == "__main__":
debug_page()