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(); await ins[0].fill('13800138000'); await ins[1].fill('123456'); await p.getByText('登 录', { exact:false }).first().click(); await p.waitForTimeout(3000); for (const [name, path] of [['首页','/mobile/home'],['会话','/mobile/messages'],['工作台','/mobile/workbench']]) { await p.goto('http://localhost:4200'+path, { waitUntil:'networkidle' }); await clear(); await p.waitForTimeout(1500); const r = await p.evaluate(() => { const btns = [...document.querySelectorAll('ui-m-tabbar button')]; const active = btns.findIndex(b => b.className.includes('text-primary')); return { labels: btns.map(b=>b.textContent.trim().replace(/\d+/g,'').trim()), activeIdx: active }; }); console.log(`${name.padEnd(6)} 激活Tab=${r.activeIdx >= 0 ? r.labels[r.activeIdx] : '无'} (期望: ${name})`); } await b.close();