| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 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: 390, height: 844 }, isMobile: false });
- 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/mobile/home', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1500);
- console.log('① /mobile/home 未登录跳转:', p.url());
- const ins = await p.locator('ui-m-field input, ui-input input').all();
- if (ins.length >= 2) { await ins[0].fill('13800138000'); await ins[1].fill('123456'); }
- await p.getByText('登 录', { exact:false }).first().click();
- await p.waitForTimeout(3500);
- console.log('② 登录后:', p.url());
- await clear(); await p.waitForTimeout(1500);
- await p.screenshot({ path: '../../.shots/mb-home.png' });
- // 底部 Tab
- const tab = await p.evaluate(() => ({
- tabbar: !!document.querySelector('ui-m-tabbar'),
- items: document.querySelectorAll('ui-m-tabbar .ui-m-tab').length,
- overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,
- }));
- console.log('③ 底部 TabBar:', JSON.stringify(tab));
- // 遍历各页
- const pages = [['messages','/mobile/messages'],['contacts','/mobile/contacts'],['workbench','/mobile/workbench'],['mine','/mobile/mine'],['deliverables','/mobile/deliverables'],['events','/mobile/events'],['projects','/mobile/projects'],['tasks','/mobile/tasks']];
- for (const [name, path] of pages) {
- await p.goto('http://localhost:4200'+path, { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1400);
- const r = await p.evaluate(() => ({
- overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,
- dk: [...document.querySelectorAll('*')].some(e => /^UI-(BUTTON|AVATAR|MODAL|SELECT|CARD|INPUT|TAG|EMPTY|SKELETON)$/.test(e.tagName)),
- }));
- console.log(` ${name.padEnd(13)} 溢出=${r.overflow?'⚠️是':'否'} 桌面件=${r.dk?'⚠️有':'无'}`);
- await p.screenshot({ path: `../../.shots/mb-${name}.png` });
- }
- console.log(errs.length ? '⚠ '+errs.slice(0,3).join(' | ') : '✅ 无控制台错误');
- await b.close();
|