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.waitForTimeout(3000); const links = await p.locator('a[href="/products"], a[href^="/products/"]').evaluateAll(a => a.map(x => ({ href: x.getAttribute('href'), text: x.textContent.trim().slice(0,24), visible: !!(x.offsetWidth || x.offsetHeight) }))); console.log(JSON.stringify(links, null, 0).slice(0, 900)); console.log('可见的 /products 链接数:', links.filter(l => l.href === '/products' && l.visible).length); await b.close();