_t.mjs 1.2 KB

123456789101112131415161718192021
  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'); await p.fill('input[type="text"][maxlength="6"]','123456');
  8. await p.click('button[type="submit"]'); await p.waitForTimeout(2500);
  9. await p.goto('http://localhost:4200/desktop/contacts', { waitUntil:'networkidle' });
  10. await clear(); await p.waitForTimeout(1800);
  11. const r = await p.evaluate(() => {
  12. const tb = document.querySelector('.toolbar');
  13. const kids = [...tb.children].map(el => ({
  14. tag: el.tagName, cls: String(el.className).slice(0,40),
  15. rect: (() => { const x = el.getBoundingClientRect(); return {x:Math.round(x.x),y:Math.round(x.y),w:Math.round(x.width),h:Math.round(x.height)}; })(),
  16. inner: el.innerHTML.slice(0,150),
  17. }));
  18. return kids;
  19. });
  20. console.log(JSON.stringify(r, null, 2));
  21. await b.close();