22 lines
1.0 KiB
JavaScript
22 lines
1.0 KiB
JavaScript
const { chromium } = require('./node_modules/playwright');
|
|
(async () => {
|
|
const browser = await chromium.launch();
|
|
const page = await browser.newPage({ viewport: { width: 1226, height: 800 } });
|
|
const errors = [];
|
|
page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
|
|
page.on('pageerror', e => errors.push('[pageerror] ' + e.message));
|
|
try {
|
|
await page.goto('http://localhost:5173/', { waitUntil: 'networkidle', timeout: 15000 });
|
|
} catch (e) {
|
|
errors.push('[nav] ' + e.message);
|
|
}
|
|
await page.waitForTimeout(2000);
|
|
await page.screenshot({ path: '/tmp/navbar_check.png' });
|
|
const title = await page.title();
|
|
const bodyLen = await page.evaluate(() => document.body?.innerText?.trim().length || 0);
|
|
const childCount = await page.evaluate(() => document.body?.children?.length || 0);
|
|
const preview = await page.evaluate(() => document.body?.innerText?.trim().substring(0, 500) || '');
|
|
console.log(JSON.stringify({ title, bodyLen, childCount, errors, preview }));
|
|
await browser.close();
|
|
})();
|