_mine.mjs 1.2 KB

1234567891011121314151617181920212223
  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(800);
  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(3000);
  11. await p.goto('http://localhost:4200/desktop/mine', { waitUntil: 'networkidle' });
  12. await clear(); await p.waitForTimeout(2200);
  13. await p.screenshot({ path: '../../.shots/v3-mine.png', fullPage: true });
  14. const r = await p.evaluate(() => {
  15. const lay = document.querySelector('.settings-layout');
  16. return {
  17. cols: lay ? getComputedStyle(lay).gridTemplateColumns : null,
  18. pageW: document.querySelector('.page')?.getBoundingClientRect().width,
  19. cards: document.querySelectorAll('ui-card').length,
  20. };
  21. });
  22. console.log(JSON.stringify(r, null, 2));
  23. await b.close();