import { chromium } from 'playwright'; const b = await chromium.launch(); // 桌面:取 CTA href、ledger signals 文案、basis note 文案 const p = await b.newPage({ viewport: { width: 1440, height: 900 } }); await p.goto('http://localhost:3210/', { waitUntil: 'domcontentloaded' }); await p.waitForTimeout(3000); const cta = p.locator('[data-testid="hero-cta"]').first(); console.log('hero-cta count=', await p.locator('[data-testid="hero-cta"]').count(), 'href=', await cta.getAttribute('href'), 'text=', (await cta.innerText()).trim().replace(/\n/g,'')); console.log('ledger-signals:', (await p.locator('[data-testid="home-ledger-signals"]').innerText()).replace(/\n/g,' | ').slice(0,220)); console.log('basis-note:', await p.locator('[data-testid="metrics-basis-note"]').innerText()); console.log('l3 heading visible:', await p.locator('#l3-signals-heading').isVisible()); await p.close(); // 移动端:CTA 是否在首屏内 + 横向溢出 const m = await b.newPage({ viewport: { width: 390, height: 844 } }); await m.goto('http://localhost:3210/', { waitUntil: 'domcontentloaded' }); await m.waitForTimeout(3000); const box = await m.locator('[data-testid="hero-cta"]').first().boundingBox(); console.log('mobile hero-cta box:', JSON.stringify(box), '在首屏内=', !!box && box.y >= 0 && box.y + box.height <= 844); const of = await m.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth })); console.log('mobile overflow:', JSON.stringify(of)); await b.close();