_f3.mjs 1.8 KB

12345678910111213141516171819202122232425262728293031323334
  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 errs = [];
  5. p.on('pageerror', e => errs.push(e.message.slice(0,120)));
  6. p.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,120)); });
  7. const clear = () => p.evaluate(() => document.querySelectorAll('vite-error-overlay').forEach(e=>e.remove()));
  8. await p.goto('http://localhost:4200/login', { waitUntil: 'networkidle' });
  9. await clear(); await p.waitForTimeout(800);
  10. const ins = await p.locator('ui-input input').all();
  11. await ins[0].fill('13800138000'); await ins[1].fill('123456');
  12. await p.getByText('登 录', { exact: false }).first().click();
  13. await p.waitForTimeout(3000);
  14. await p.goto('http://localhost:4200/desktop/chat/zhixia', { waitUntil:'networkidle' });
  15. await clear(); await p.waitForTimeout(2000);
  16. const r = await p.evaluate(() => ({
  17. railItems: document.querySelectorAll('.rail-item').length,
  18. previewBtns: document.querySelectorAll('.rail-actions ui-button').length,
  19. dlBtns: document.querySelectorAll('.dl-btn').length,
  20. convActiveShadow: getComputedStyle(document.querySelector('.conv-row.active')).boxShadow,
  21. }));
  22. console.log(JSON.stringify(r, null, 2));
  23. await p.screenshot({ path: '../../.shots/f3-chat.png' });
  24. // 点预览验证弹窗
  25. if (r.previewBtns > 0) {
  26. await p.locator('.rail-actions ui-button button').first().click();
  27. await p.waitForTimeout(1200);
  28. const modal = await p.locator('ui-modal').first().isVisible().catch(()=>false);
  29. console.log('预览弹窗可见:', modal);
  30. await p.screenshot({ path: '../../.shots/f3-preview.png' });
  31. }
  32. console.log(errs.length ? '⚠ '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误');
  33. await b.close();