import { chromium } from 'playwright'; const b = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' }); const ctx = await b.newContext({ viewport: { width: 1440, height: 900 } }); const p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message.slice(0,120))); p.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,120)); }); await p.goto('http://localhost:4200/', { waitUntil: 'domcontentloaded' }); await p.evaluate(() => { document.querySelectorAll('vite-error-overlay').forEach(e => e.remove()); }); await p.goto('http://localhost:4200/login', { waitUntil: 'networkidle' }); await p.evaluate(() => { document.querySelectorAll('vite-error-overlay').forEach(e => e.remove()); }); await p.waitForTimeout(700); await p.fill('input[type="tel"]', '13800138000'); await p.fill('input[type="text"][maxlength="6"]', '123456'); await p.click('button[type="submit"]'); await p.waitForTimeout(3000); await p.goto('http://localhost:4200/desktop/workbench', { waitUntil: 'networkidle' }); await p.waitForTimeout(2500); const r = await p.evaluate(() => ({ demoStrip: !!document.querySelector('.demo-strip'), demoText: /演示数据|未连接真实服务/.test(document.body.innerText), uiCards: document.querySelectorAll('ui-card').length, uiStats: document.querySelectorAll('ui-statistic').length, uiProgress: document.querySelectorAll('ui-progress').length, overflowX: document.documentElement.scrollWidth > document.documentElement.clientWidth, })); console.log(JSON.stringify(r, null, 2)); await p.screenshot({ path: '../../.shots/final-workbench-1440.png' }); console.log(errs.length ? '⚠ 错误: '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误'); await b.close();