import { chromium } from 'playwright'; const base = 'http://localhost:4200'; const b = await chromium.launch({ channel: 'msedge' }); const ctx = await b.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true, userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 Mobile/15E148 Safari/604.1' }); const p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message)); await p.goto(base + '/login'); await p.waitForTimeout(900); await p.locator('input').nth(0).fill('13800000000'); await p.getByRole('button', { name: /获取验证码/ }).first().click(); await p.waitForTimeout(400); await p.locator('input').nth(1).fill('123456'); await p.getByRole('button', { name: /^登\s*录$/ }).first().click(); await p.waitForTimeout(3500); // 从列表页点进真实详情 await p.goto(base + '/mobile/projects'); await p.waitForTimeout(1500); await p.locator('.card.project').first().click(); await p.waitForTimeout(1200); console.log('project url', p.url().replace(base, '')); await p.screenshot({ path: '.tmp-shots/project-real.png' }); await p.goto(base + '/mobile/tasks'); await p.waitForTimeout(1500); await p.locator('.card.task').first().click(); await p.waitForTimeout(1200); console.log('task url', p.url().replace(base, '')); await p.screenshot({ path: '.tmp-shots/task-real.png' }); await p.goto(base + '/mobile/contacts'); await p.waitForTimeout(1500); await p.locator('.row').first().click(); await p.waitForTimeout(1500); console.log('agent url', p.url().replace(base, '')); await p.screenshot({ path: '.tmp-shots/agent-real.png' }); console.log('errs', [...new Set(errs)].slice(0, 5)); await b.close();