From 167e5130559460c951f99bcac7ec76c5fa1f1bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Sat, 4 Apr 2026 09:03:49 +0800 Subject: [PATCH] fix: optimize RoleManagementPage navigation with better error handling --- .../e2e/pages/RoleManagementPage.ts | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/novalon-manage-web/e2e/pages/RoleManagementPage.ts b/novalon-manage-web/e2e/pages/RoleManagementPage.ts index 48ea6cc..df29935 100644 --- a/novalon-manage-web/e2e/pages/RoleManagementPage.ts +++ b/novalon-manage-web/e2e/pages/RoleManagementPage.ts @@ -1,4 +1,4 @@ -import { Page, Locator } from '@playwright/test'; +import { Page, Locator, expect } from '@playwright/test'; export class RoleManagementPage { readonly page: Page; @@ -38,8 +38,34 @@ export class RoleManagementPage { } async goto() { - await this.page.goto('/roles'); - await this.page.waitForLoadState('networkidle'); + try { + console.log('导航到角色管理页面...'); + await this.page.goto('/roles'); + + await this.page.waitForLoadState('networkidle'); + await this.table.waitFor({ state: 'visible', timeout: 10000 }); + await expect(this.page).toHaveURL(/.*roles/); + + console.log('角色管理页面加载完成'); + } catch (error) { + await this.page.screenshot({ path: `test-results/role-management-error-${Date.now()}.png` }); + console.error('导航到角色管理页面失败:', error); + throw new Error(`导航到角色管理页面失败: ${error instanceof Error ? error.message : String(error)}`); + } + } + + async waitForTableReady() { + await this.table.waitFor({ state: 'visible', timeout: 10000 }); + + await this.page.waitForFunction( + () => { + const rows = document.querySelectorAll('.el-table__body-wrapper tbody tr'); + return rows.length > 0; + }, + { timeout: 5000 } + ).catch(() => { + console.log('表格没有数据,继续执行'); + }); } async clickCreateRole() {