feat(api/web): 实现API请求签名验证功能并优化测试环境配置
refactor(db): 重构查询条件类到query目录下 test: 添加登录流程测试脚本和测试数据 chore: 添加crypto-js依赖用于签名验证 ci: 配置测试环境数据库和端口设置
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
检查登录页面结构
|
||||
"""
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
import time
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
|
||||
# 访问登录页面
|
||||
page.goto("http://localhost:3002/login")
|
||||
page.wait_for_load_state("networkidle")
|
||||
|
||||
# 截图
|
||||
page.screenshot(path="/tmp/login_page.png")
|
||||
|
||||
# 获取页面内容
|
||||
print("页面URL:", page.url)
|
||||
print("\n页面标题:", page.title())
|
||||
|
||||
# 查找所有输入框
|
||||
inputs = page.locator('input').all()
|
||||
print(f"\n找到 {len(inputs)} 个输入框:")
|
||||
for i, inp in enumerate(inputs):
|
||||
try:
|
||||
placeholder = inp.get_attribute('placeholder')
|
||||
input_type = inp.get_attribute('type')
|
||||
print(f" {i+1}. type={input_type}, placeholder={placeholder}")
|
||||
except:
|
||||
pass
|
||||
|
||||
# 查找所有按钮
|
||||
buttons = page.locator('button').all()
|
||||
print(f"\n找到 {len(buttons)} 个按钮:")
|
||||
for i, btn in enumerate(buttons):
|
||||
try:
|
||||
text = btn.text_content()
|
||||
print(f" {i+1}. {text}")
|
||||
except:
|
||||
pass
|
||||
|
||||
# 尝试登录
|
||||
print("\n尝试登录...")
|
||||
|
||||
# 填写用户名
|
||||
username_input = page.locator('input[type="text"], input:not([type])').first
|
||||
username_input.fill("admin")
|
||||
print("填写用户名: admin")
|
||||
|
||||
# 填写密码
|
||||
password_input = page.locator('input[type="password"]').first
|
||||
password_input.fill("Test@123")
|
||||
print("填写密码: Test@123")
|
||||
|
||||
# 点击登录按钮
|
||||
login_button = page.locator('button:has-text("登录")').first
|
||||
login_button.click()
|
||||
print("点击登录按钮")
|
||||
|
||||
# 等待跳转
|
||||
time.sleep(5)
|
||||
|
||||
print(f"\n登录后URL: {page.url}")
|
||||
page.screenshot(path="/tmp/after_login.png")
|
||||
|
||||
# 检查是否有错误消息
|
||||
error_msg = page.locator('.el-message--error, .error-message').first
|
||||
if error_msg.is_visible():
|
||||
print(f"错误消息: {error_msg.text_content()}")
|
||||
|
||||
browser.close()
|
||||
Reference in New Issue
Block a user