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()