.tmp-details.mjs 1.7 KB

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