_contacts.mjs 1.5 KB

123456789101112131415161718192021222324252627282930
  1. import { chromium } from 'playwright';
  2. const b = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' });
  3. const p = await (await b.newContext({ viewport: { width: 1440, height: 900 } })).newPage();
  4. const clear = () => p.evaluate(() => document.querySelectorAll('vite-error-overlay').forEach(e=>e.remove()));
  5. await p.goto('http://localhost:4200/login', { waitUntil: 'networkidle' });
  6. await clear(); await p.waitForTimeout(600);
  7. await p.fill('input[type="tel"]', '13800138000');
  8. await p.fill('input[type="text"][maxlength="6"]', '123456');
  9. await p.click('button[type="submit"]');
  10. await p.waitForTimeout(3000);
  11. await p.goto('http://localhost:4200/desktop/contacts', { waitUntil: 'networkidle' });
  12. await clear(); await p.waitForTimeout(2000);
  13. // 检查「全部」Tab 下方是否有异常空元素
  14. const probe = await p.evaluate(() => {
  15. const out = [];
  16. document.querySelectorAll('section, h2.section-title, .grid, ul.rows').forEach(el => {
  17. const r = el.getBoundingClientRect();
  18. out.push({
  19. tag: el.tagName + (el.className ? '.' + String(el.className).split(' ')[0] : ''),
  20. h: Math.round(r.height),
  21. text: (el.textContent || '').trim().slice(0, 20),
  22. });
  23. });
  24. return out;
  25. });
  26. console.log('=== 「全部」Tab 下的区块 ===');
  27. probe.forEach(x => console.log(` ${x.tag.padEnd(24)} h=${String(x.h).padStart(4)} "${x.text}"`));
  28. await p.screenshot({ path: '../../.shots/dk-contacts-all.png' });
  29. await b.close();