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() {