import { chromium } from 'playwright'; const b = await chromium.launch(); const p = await b.newPage({ viewport: { width: 1440, height: 900 } }); await p.goto('http://localhost:3210/', { waitUntil: 'domcontentloaded' }); await p.waitForSelector('nav[aria-label="主导航"]', { timeout: 15000 }); await p.waitForTimeout(2500); const nav = p.locator('nav[aria-label="主导航"]'); const btn = nav.locator('button:has-text("能力")'); await btn.hover(); await p.waitForTimeout(700); // 找到面板容器:按钮的父级里除按钮外的文本 const html = await nav.evaluate(n => n.outerHTML); console.log('NAV HTML length', html.length); const txt = await nav.innerText(); console.log('--- innerText after hovering 能力 ---'); console.log(txt.replace(/\n{2,}/g, '\n').slice(0, 900)); await b.close();