74 lines
2.5 KiB
JavaScript
74 lines
2.5 KiB
JavaScript
const { chromium } = require('playwright');
|
|
const fs = require('fs');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const ctx = await browser.newContext({
|
|
viewport: { width: 1584, height: 800 },
|
|
recordVideo: { dir: '/tmp/v91-videos/' }
|
|
});
|
|
const page = await ctx.newPage();
|
|
|
|
const errors = [];
|
|
const consoleErrors = [];
|
|
const consoleInfos = [];
|
|
const networkFails = [];
|
|
const requests = [];
|
|
|
|
page.on('pageerror', e => errors.push({ type: 'pageerror', msg: e.message }));
|
|
page.on('console', m => {
|
|
const t = m.type();
|
|
const txt = m.text();
|
|
if (t === 'error') consoleErrors.push(txt);
|
|
else if (t === 'info') consoleInfos.push(txt);
|
|
});
|
|
page.on('requestfailed', r => networkFails.push({
|
|
url: r.url(),
|
|
reason: r.failure() ? r.failure().errorText : 'unknown'
|
|
}));
|
|
page.on('response', r => {
|
|
if (r.status() >= 400) {
|
|
requests.push({ url: r.url(), status: r.status() });
|
|
}
|
|
});
|
|
|
|
await page.goto('https://weval-consulting.com/wevia-ia/wevia-admin.php', { waitUntil: 'networkidle', timeout: 45000 });
|
|
await page.waitForTimeout(5000);
|
|
|
|
await page.screenshot({ path: '/tmp/v91-wevia-admin-loaded.png', fullPage: true });
|
|
|
|
const pageInfo = await page.evaluate(() => ({
|
|
title: document.title,
|
|
url: location.href,
|
|
bodyLen: document.body.innerText.length,
|
|
hasLoginForm: !!document.querySelector('input[type="password"]'),
|
|
scripts: [...document.querySelectorAll('script[src]')].map(s => s.src)
|
|
}));
|
|
|
|
const summary = {
|
|
ts: new Date().toISOString(),
|
|
page: pageInfo,
|
|
errors_count: errors.length,
|
|
console_errors_count: consoleErrors.length,
|
|
console_infos_count: consoleInfos.length,
|
|
network_fails_count: networkFails.length,
|
|
http_errors_count: requests.length,
|
|
errors: errors.slice(0, 20),
|
|
console_errors: consoleErrors.slice(0, 20),
|
|
network_fails: networkFails.slice(0, 20),
|
|
http_errors: requests.slice(0, 30)
|
|
};
|
|
|
|
await ctx.close();
|
|
await browser.close();
|
|
|
|
fs.writeFileSync('/var/www/html/api/playwright-v91-wevia-admin-debug.json', JSON.stringify(summary, null, 2));
|
|
console.log(JSON.stringify({
|
|
title: pageInfo.title,
|
|
errors: errors.length,
|
|
console_errors: consoleErrors.length,
|
|
network_fails: networkFails.length,
|
|
http_400plus: requests.length
|
|
}));
|
|
})();
|