_dbg2.mjs 1.5 KB

1234567891011121314151617181920212223242526272829
  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: 1280, height: 1000 } })).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(700);
  7. const ins = await p.locator('ui-input input').all();
  8. await ins[0].fill('13800138000'); await ins[1].fill('123456');
  9. await p.getByText('登 录', { exact:false }).first().click();
  10. await p.waitForTimeout(2800);
  11. await p.goto('http://localhost:4200/desktop/contacts', { waitUntil:'networkidle' });
  12. await clear(); await p.waitForTimeout(1800);
  13. const info = await p.evaluate(() => {
  14. const out = [];
  15. // 找所有高度异常(>60px)且内容为空的元素
  16. document.querySelectorAll('.page *').forEach(el => {
  17. const r = el.getBoundingClientRect();
  18. const txt = (el.textContent||'').trim();
  19. if (r.height > 50 && txt.length === 0) {
  20. out.push({ tag: el.tagName, cls: String(el.className).slice(0,60),
  21. h: Math.round(r.height), w: Math.round(r.width), y: Math.round(r.y) });
  22. }
  23. });
  24. return out.slice(0, 12);
  25. });
  26. console.log('高度>50px 且无文字的元素:');
  27. info.forEach(x => console.log(` ${x.tag.padEnd(10)} .${x.cls.padEnd(42)} ${x.w}x${x.h} @y=${x.y}`));
  28. await p.screenshot({ path: '../../.shots/dbg-contacts.png' });
  29. await b.close();