_tab.mjs 1.3 KB

12345678910111213141516171819202122232425
  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: 390, height: 844 } })).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(900);
  7. const ins = await p.locator('ui-input input, ui-m-field input').all();
  8. if (ins.length>=2) { 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/mobile/home', { waitUntil:'networkidle' });
  12. await clear(); await p.waitForTimeout(1800);
  13. const r = await p.evaluate(() => {
  14. const tb = document.querySelector('ui-m-tabbar');
  15. if (!tb) return { err: 'no tabbar' };
  16. const btns = tb.querySelectorAll('button');
  17. return {
  18. buttonCount: btns.length,
  19. labels: [...btns].map(b => b.textContent.trim().slice(0,8)),
  20. onIdx: [...btns].findIndex(b => b.classList.contains('on')),
  21. classes: btns[0] ? btns[0].className.slice(0,60) : null,
  22. };
  23. });
  24. console.log(JSON.stringify(r, null, 2));
  25. await b.close();