Files
telegram-management-system/frontend/simple-page-test.js
你的用户名 237c7802e5
Some checks failed
Deploy / deploy (push) Has been cancelled
Initial commit: Telegram Management System
Full-stack web application for Telegram management
- Frontend: Vue 3 + Vben Admin
- Backend: NestJS
- Features: User management, group broadcast, statistics

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 15:37:50 +08:00

123 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { chromium } = require('playwright');
async function testPageAccess() {
console.log('🚀 启动页面访问测试');
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
try {
// 1. 访问首页
console.log('📍 访问首页: http://localhost:8890');
await page.goto('http://localhost:8890');
await page.waitForLoadState('networkidle');
// 2. 截图查看当前状态
await page.screenshot({ path: 'current-page-state.png' });
console.log('📸 页面截图已保存: current-page-state.png');
// 3. 检查页面标题
const title = await page.title();
console.log('📄 页面标题:', title);
// 4. 检查是否需要登录
const loginForm = await page.locator('form').count();
const loginButton = await page.locator('button:has-text("登录"), button:has-text("Login")').count();
console.log('🔐 登录表单数量:', loginForm);
console.log('🔐 登录按钮数量:', loginButton);
if (loginButton > 0) {
console.log(' 需要登录,尝试使用默认凭据...');
// 查找用户名输入框
const usernameInput = page.locator('input[type="text"], input[placeholder*="用户"], input[placeholder*="账号"]').first();
if (await usernameInput.isVisible()) {
await usernameInput.fill('admin');
console.log('✅ 用户名已填写');
}
// 查找密码输入框
const passwordInput = page.locator('input[type="password"]').first();
if (await passwordInput.isVisible()) {
await passwordInput.fill('111111');
console.log('✅ 密码已填写');
}
// 点击登录按钮
const loginBtn = page.locator('button:has-text("登录"), button:has-text("Login")').first();
if (await loginBtn.isVisible()) {
await loginBtn.click();
console.log('✅ 点击登录按钮');
// 等待登录完成
await page.waitForTimeout(3000);
await page.waitForLoadState('networkidle');
}
}
// 5. 登录后截图
await page.screenshot({ path: 'after-login-state.png' });
console.log('📸 登录后截图已保存: after-login-state.png');
// 6. 检查是否有菜单
const menuElements = await page.locator('.ivu-menu, .menu, [class*="menu"]').count();
console.log('📋 菜单元素数量:', menuElements);
if (menuElements > 0) {
console.log('✅ 发现菜单,查找账号管理...');
// 查找账号管理菜单
const accountMenu = page.locator('text=账号管理, text=Account').first();
if (await accountMenu.isVisible()) {
console.log('✅ 找到账号管理菜单');
await accountMenu.click();
await page.waitForTimeout(1000);
// 查找统一注册系统
const unifiedMenu = page.locator('text=统一注册系统, text=Unified Register').first();
if (await unifiedMenu.isVisible()) {
console.log('✅ 找到统一注册系统菜单');
await unifiedMenu.click();
await page.waitForTimeout(2000);
// 检查页面URL
const currentURL = page.url();
console.log('🔗 当前URL:', currentURL);
if (currentURL.includes('unifiedRegister')) {
console.log('🎉 成功访问统一注册系统页面!');
// 最终截图
await page.screenshot({ path: 'unified-register-page.png' });
console.log('📸 统一注册页面截图已保存: unified-register-page.png');
// 检查页面元素
const pageTitle = await page.locator('h1, h2, h3').first().textContent();
console.log('📋 页面标题:', pageTitle);
const strategySections = await page.locator('text=批量注册, text=连续注册').count();
console.log('⚙️ 策略选项数量:', strategySections);
} else {
console.log('❌ 未跳转到统一注册系统页面');
}
} else {
console.log('❌ 未找到统一注册系统菜单');
}
} else {
console.log('❌ 未找到账号管理菜单');
}
} else {
console.log('❌ 未发现菜单元素');
}
} catch (error) {
console.error('❌ 测试过程中出现错误:', error.message);
await page.screenshot({ path: 'error-state.png' });
} finally {
await browser.close();
console.log('🏁 测试完成');
}
}
testPageAccess().catch(console.error);