| 12345678910111213141516171819202122232425 |
- import { chromium } from 'playwright';
- const b = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' });
- const p = await (await b.newContext({ viewport: { width: 390, height: 844 } })).newPage();
- const clear = () => p.evaluate(() => document.querySelectorAll('vite-error-overlay').forEach(e=>e.remove()));
- await p.goto('http://localhost:4200/login', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(900);
- const ins = await p.locator('ui-input input, ui-m-field input').all();
- if (ins.length>=2) { await ins[0].fill('13800138000'); await ins[1].fill('123456'); }
- await p.getByText('登 录', { exact:false }).first().click();
- await p.waitForTimeout(3000);
- await p.goto('http://localhost:4200/mobile/home', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(1800);
- const r = await p.evaluate(() => {
- const tb = document.querySelector('ui-m-tabbar');
- if (!tb) return { err: 'no tabbar' };
- const btns = tb.querySelectorAll('button');
- return {
- buttonCount: btns.length,
- labels: [...btns].map(b => b.textContent.trim().slice(0,8)),
- onIdx: [...btns].findIndex(b => b.classList.contains('on')),
- classes: btns[0] ? btns[0].className.slice(0,60) : null,
- };
- });
- console.log(JSON.stringify(r, null, 2));
- await b.close();
|