You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
JavaScript
46 lines
1.4 KiB
JavaScript
const { chromium } = require('playwright');
|
|
|
|
(async () => {
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
|
|
// 收集console日志
|
|
page.on('console', msg => {
|
|
if (msg.type() === 'error' || msg.type() === 'warning') {
|
|
console.log(`[${msg.type().toUpperCase()}]`, msg.text());
|
|
}
|
|
});
|
|
// 收集网络请求
|
|
page.on('response', resp => {
|
|
if (resp.url().includes('/api/') && !resp.url().includes('login')) {
|
|
console.log(`[API] ${resp.status()} ${resp.url()}`);
|
|
}
|
|
});
|
|
|
|
// 登录
|
|
await page.goto('http://127.0.0.1/admin/login');
|
|
await page.waitForTimeout(500);
|
|
await page.fill('input[type="text"]', 'admin');
|
|
await page.fill('input[type="password"]', 'admin123');
|
|
await page.click('button:has-text("登录")');
|
|
await page.waitForTimeout(2000);
|
|
|
|
// 导航到产量报表
|
|
console.log('\n--- 导航到产量报表 ---');
|
|
await page.goto('http://127.0.0.1/admin/production');
|
|
await page.waitForTimeout(5000);
|
|
|
|
// 检查dateRange reactive值
|
|
const dateValue = await page.evaluate(() => {
|
|
// 找到Vue实例
|
|
const app = document.querySelector('#app');
|
|
return {
|
|
inputValues: Array.from(document.querySelectorAll('.el-date-editor input')).map(e => e.value),
|
|
today: new Date().toISOString().split('T')[0]
|
|
};
|
|
});
|
|
console.log('\n日期值:', JSON.stringify(dateValue));
|
|
|
|
await browser.close();
|
|
})();
|