36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
const { chromium } = require('playwright');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
|
|
console.log('打开登录页...');
|
|
await page.goto('http://localhost:5173/login', { waitUntil: 'networkidle', timeout: 15000 });
|
|
|
|
console.log('等待页面加载...');
|
|
await page.waitForTimeout(2000);
|
|
|
|
// 打印页面内容用于调试
|
|
const html = await page.content();
|
|
console.log('页面标题:', await page.title());
|
|
|
|
console.log('填写用户名...');
|
|
await page.fill('input[placeholder="请输入用户名"]', 'admin', { timeout: 5000 });
|
|
|
|
console.log('填写密码...');
|
|
await page.fill('input[placeholder="请输入密码"]', 'admin', { timeout: 5000 });
|
|
|
|
console.log('点击登录...');
|
|
await page.click('button:has-text("登录")');
|
|
|
|
console.log('等待跳转...');
|
|
await page.waitForTimeout(3000);
|
|
|
|
console.log('截取首页...');
|
|
await page.screenshot({ path: '/tmp/admin_home.png', fullPage: true });
|
|
|
|
console.log('完成!截图保存在 /tmp/admin_home.png');
|
|
await browser.close();
|
|
process.exit(0);
|
|
})();
|