Files
kt-financial-system/temp-tests/test-simple-menu.js
woshiqp465 9683b940bf feat: 配置开发环境和清理项目结构
- 修改默认路由重定向到首页 (/home)
- 配置开发服务器使用5667端口
- 整理测试文件到temp-tests目录
- 优化项目结构便于开发和部署

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-15 21:35:49 +08:00

56 lines
1.6 KiB
JavaScript

import { chromium } from 'playwright';
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
try {
console.log('访问系统...');
await page.goto('http://localhost:5670');
// 等待页面加载
await page.waitForTimeout(5000);
// 尝试获取当前URL
console.log('当前URL:', page.url());
// 如果在登录页,执行登录
if (page.url().includes('login')) {
console.log('需要登录...');
// 等待登录表单出现
await page.waitForSelector('input[type="text"]', { timeout: 5000 });
// 使用更通用的选择器
const usernameInput = await page.locator('input[type="text"]').first();
const passwordInput = await page.locator('input[type="password"]').first();
const loginButton = await page.locator('button[type="submit"]').first();
await usernameInput.fill('admin');
await passwordInput.fill('111111');
await loginButton.click();
await page.waitForTimeout(5000);
}
console.log('检查菜单...');
// 获取所有菜单文本
const menuTexts = await page.locator('.ant-menu-title-content').allTextContents();
console.log('\n当前菜单:');
menuTexts.forEach((text, i) => {
console.log(`${i+1}. ${text}`);
});
// 截图
await page.screenshot({ path: 'simple-menu-test.png', fullPage: true });
console.log('\n截图: simple-menu-test.png');
} catch (error) {
console.error('错误:', error.message);
} finally {
await page.waitForTimeout(3000);
await browser.close();
}
})();