_v3.mjs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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(1500);
  7. // ui-input 内部是原生 input,直接按位置填
  8. const inputs = await p.locator('ui-input input').all();
  9. console.log('找到 ui-input 内原生 input 数量:', inputs.length);
  10. if (inputs.length >= 2) {
  11. await inputs[0].fill('13800138000');
  12. await inputs[1].fill('123456');
  13. }
  14. // 提交按钮:找「登 录」文本
  15. await p.getByText('登 录', { exact: false }).first().click();
  16. await p.waitForTimeout(3500);
  17. console.log('登录后 URL:', p.url());
  18. await clear();
  19. await p.goto('http://localhost:4200/desktop/mine', { waitUntil: 'networkidle' });
  20. await clear(); await p.waitForTimeout(2500);
  21. await p.screenshot({ path: '../../.shots/v2-mine.png' });
  22. const probe = await p.evaluate(() => {
  23. const thumbs = [...document.querySelectorAll('.thumb')].map(t => {
  24. const nav = t.querySelector('.thumb-nav'), main = t.querySelector('.thumb-main');
  25. return {
  26. palette: t.getAttribute('data-preview-palette'),
  27. navBg: nav ? getComputedStyle(nav).backgroundColor : '-',
  28. mainBg: main ? getComputedStyle(main).backgroundColor : '-',
  29. };
  30. });
  31. return {
  32. thumbCount: thumbs.length,
  33. thumbs,
  34. hasUsageSection: /使用端/.test(document.body.innerText),
  35. };
  36. });
  37. console.log('\n=== 我的页 ===');
  38. console.log('缩略图数量:', probe.thumbCount);
  39. probe.thumbs.forEach(t => console.log(` ${(t.palette||'').padEnd(10)} nav=${t.navBg} main=${t.mainBg}`));
  40. console.log('「使用端」区块仍存在:', probe.hasUsageSection);
  41. await p.screenshot({ path: '../../.shots/v2-mine-final.png' });
  42. await b.close();