| 123456789101112131415161718192021222324252627282930313233343536 |
- 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)); });
- const clear = () => p.evaluate(() => document.querySelectorAll('vite-error-overlay').forEach(e=>e.remove()));
- await p.goto('http://localhost:4200/login', { waitUntil: 'networkidle' });
- await clear();
- await p.waitForTimeout(600);
- 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);
- const pages = [
- ['workbench','/desktop/workbench'], ['chat','/desktop/chat'], ['contacts','/desktop/contacts'],
- ['projects','/desktop/projects'], ['events','/desktop/events'], ['tasks','/desktop/tasks'],
- ['deliverables','/desktop/deliverables'], ['agent','/desktop/agent/zhixia'], ['mine','/desktop/mine'],
- ];
- for (const [name, path] of pages) {
- await p.goto('http://localhost:4200' + path, { waitUntil: 'networkidle' });
- await clear();
- await p.waitForTimeout(1800);
- await p.screenshot({ path: `../../.shots/dk-${name}.png` });
- const r = await p.evaluate(() => ({
- overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,
- demo: /演示数据|未连接真实服务/.test(document.body.innerText),
- h1: document.querySelector('h1')?.textContent?.trim()?.slice(0,10),
- }));
- console.log(` ${name.padEnd(13)} h1=${(r.h1||'-').padEnd(10)} 溢出=${r.overflow?'⚠️是':'否'} demo文案=${r.demo?'⚠️有':'无'}`);
- }
- console.log(errs.length ? '\n⚠ 错误: '+errs.slice(0,3).join(' | ') : '\n✅ 全部页面无控制台错误');
- await b.close();
|