/** 登录页结构诊断:把实际渲染出来的表单元素全部打出来 */
|
const { chromium } = require('playwright');
|
|
(async () => {
|
const browser = await chromium.launch({ headless: true });
|
const page = await browser.newPage({ viewport: { width: 1600, height: 900 } });
|
const errors = [];
|
page.on('pageerror', (e) => errors.push('pageerror: ' + e.message));
|
page.on('console', (m) => {
|
if (m.type() === 'error') errors.push('console: ' + m.text());
|
});
|
page.on('requestfailed', (r) =>
|
errors.push('reqfail: ' + r.url() + ' ' + (r.failure() || {}).errorText),
|
);
|
|
await page.goto('http://127.0.0.1:5666/auth/login', { waitUntil: 'domcontentloaded' });
|
await page.waitForTimeout(8000);
|
|
console.log('URL:', page.url());
|
console.log('TITLE:', await page.title());
|
const bodyText = (await page.locator('body').innerText().catch(() => '')).slice(0, 800);
|
console.log('--- 可见文本 ---');
|
console.log(bodyText);
|
|
console.log('--- input 元素 ---');
|
for (const el of await page.locator('input').all()) {
|
console.log(
|
JSON.stringify({
|
type: await el.getAttribute('type'),
|
name: await el.getAttribute('name'),
|
autocomplete: await el.getAttribute('autocomplete'),
|
placeholder: await el.getAttribute('placeholder'),
|
id: await el.getAttribute('id'),
|
visible: await el.isVisible().catch(() => false),
|
}),
|
);
|
}
|
|
console.log('--- button/role=radio 元素 ---');
|
for (const el of await page.locator('button, [role=radio], .ant-radio-wrapper').all()) {
|
const t = (await el.innerText().catch(() => '')).trim().slice(0, 40);
|
if (t) console.log(JSON.stringify({ tag: await el.evaluate((n) => n.tagName), text: t }));
|
}
|
|
console.log('--- 错误 ---');
|
console.log(errors.slice(0, 20).join('\n') || '(无)');
|
await page.screenshot({
|
path: require('node:path').join(__dirname, 'qr-export-test-out', 'diag-login.png'),
|
});
|
await browser.close();
|
})();
|