| 12345678910111213141516171819202122232425262728293031323334 |
- 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: 1440, height: 900 } })).newPage();
- const errs = [];
- p.on('pageerror', e => errs.push(e.message.slice(0,120)));
- p.on('console', m => { if (m.type()==='error') errs.push(m.text().slice(0,120)); });
- 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(800);
- const ins = await p.locator('ui-input input').all();
- 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/desktop/chat/zhixia', { waitUntil:'networkidle' });
- await clear(); await p.waitForTimeout(2000);
- const r = await p.evaluate(() => ({
- railItems: document.querySelectorAll('.rail-item').length,
- previewBtns: document.querySelectorAll('.rail-actions ui-button').length,
- dlBtns: document.querySelectorAll('.dl-btn').length,
- convActiveShadow: getComputedStyle(document.querySelector('.conv-row.active')).boxShadow,
- }));
- console.log(JSON.stringify(r, null, 2));
- await p.screenshot({ path: '../../.shots/f3-chat.png' });
- // 点预览验证弹窗
- if (r.previewBtns > 0) {
- await p.locator('.rail-actions ui-button button').first().click();
- await p.waitForTimeout(1200);
- const modal = await p.locator('ui-modal').first().isVisible().catch(()=>false);
- console.log('预览弹窗可见:', modal);
- await p.screenshot({ path: '../../.shots/f3-preview.png' });
- }
- console.log(errs.length ? '⚠ '+errs.slice(0,2).join(' | ') : '✅ 无控制台错误');
- await b.close();
|