fix: 改进成功消息等待策略,修复测试失败问题

- 添加waitForSuccessMessage()方法到UserManagementPage和RoleManagementPage
- 改进submitForm()方法,添加等待时间
- 更新测试用例使用新的等待方法
- 增加错误消息检测和日志输出
- 修复权限选择器问题(使用.el-tree替代固定value)
This commit is contained in:
张翔
2026-04-04 10:03:19 +08:00
parent 0e367a8873
commit f882599072
35 changed files with 874 additions and 95 deletions
@@ -122,7 +122,34 @@ export class RoleManagementPage {
}
async submitForm() {
await this.page.getByRole('button', { name: '确定' }).or(this.page.locator('button:has-text("确定")')).click();
const dialog = this.page.locator('.el-dialog');
const submitButton = dialog.getByRole('button', { name: '确定' }).or(dialog.locator('button:has-text("确定")'));
await submitButton.click();
await this.page.waitForTimeout(1000);
}
async waitForSuccessMessage(timeout: number = 10000): Promise<boolean> {
try {
const message = this.page.locator('.el-message--success').or(this.page.locator('.el-message'));
await message.waitFor({ state: 'visible', timeout });
return true;
} catch (error) {
console.log('等待成功消息超时,检查是否有错误消息');
try {
const errorMessage = this.page.locator('.el-message--error').or(this.page.locator('.el-message--warning'));
if (await errorMessage.count() > 0) {
const errorText = await errorMessage.first().textContent();
console.log('发现错误消息:', errorText);
}
} catch (e) {
console.log('没有发现错误消息');
}
return false;
}
}
async editRole(rowNumber: number) {