主要改进: - 新增统一测试器 (universal_tester.py) 支持多种测试模式 - 优化测试报告生成器,支持汇总报告和操作截图 - 增强探索器 DFS 算法和状态指纹识别 - 新增智能测试配置 (smart_test.yaml) - 改进 AI 模型集成 (GLM/Gemini 支持) - 添加开发调试工具和文档
This commit is contained in:
60
inspect_dom.py
Normal file
60
inspect_dom.py
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
from src.browser.controller import BrowserController
|
||||
|
||||
def inspect_page_elements():
|
||||
browser = BrowserController(headless=False)
|
||||
try:
|
||||
browser.start()
|
||||
browser.goto('http://47.99.105.253:8084')
|
||||
browser.wait(2000)
|
||||
|
||||
# Login
|
||||
print("Logging in...")
|
||||
browser.page.locator('input[placeholder*="用户名"]').fill('admin')
|
||||
browser.page.locator('input[type="password"]').fill('password')
|
||||
browser.page.locator('button:has-text("登录")').click()
|
||||
browser.wait(5000)
|
||||
|
||||
print(f"Current URL: {browser.page.url}")
|
||||
|
||||
# Comprehensive DOM inspection
|
||||
inspection = browser.page.evaluate('''() => {
|
||||
const results = {
|
||||
summary: {
|
||||
total_elements: document.querySelectorAll("*").length,
|
||||
visible_elements: Array.from(document.querySelectorAll("*")).filter(el => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.width > 0 && rect.height > 0;
|
||||
}).length
|
||||
},
|
||||
potential_menus: Array.from(document.querySelectorAll(".ant-menu-item, .ant-menu-submenu-title, li, a, button")).filter(el => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
return rect.width > 0 && rect.height > 0 && el.innerText.trim().length > 0;
|
||||
}).map(el => ({
|
||||
tag: el.tagName,
|
||||
text: el.innerText.split('\\n')[0].trim(),
|
||||
className: el.className,
|
||||
id: el.id,
|
||||
role: el.getAttribute("role")
|
||||
})).slice(0, 50),
|
||||
sidebar: !!document.querySelector("aside, .ant-layout-sider, .bg-sidebar-deep"),
|
||||
sidebar_classes: document.querySelector("aside, .ant-layout-sider, .bg-sidebar-deep")?.className
|
||||
};
|
||||
return results;
|
||||
}''')
|
||||
|
||||
print(f"\nInspection Results:")
|
||||
print(f"Total Elements: {inspection['summary']['total_elements']}")
|
||||
print(f"Visible Elements: {inspection['summary']['visible_elements']}")
|
||||
print(f"Sidebar Present: {inspection['sidebar']} (Classes: {inspection['sidebar_classes']})")
|
||||
print("\nTop 50 Clickable candidates:")
|
||||
for item in inspection['potential_menus']:
|
||||
print(f"- [{item['tag']}] '{item['text']}' (Role: {item['role']}, Class: {item['className']})")
|
||||
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
inspect_page_elements()
|
||||
Reference in New Issue
Block a user