fix: optimize all Page Object navigation with better error handling
- MenuManagementPage: add tree/table wait and error handling - SystemConfigPage: add table wait and error handling - DictionaryManagementPage: add table wait and error handling - FileManagementPage: add table wait and error handling - OperationLogPage: add table wait and error handling - LoginLogPage: add table wait and error handling - ExceptionLogPage: add table wait and error handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Page, Locator } from '@playwright/test';
|
||||
import { Page, Locator, expect } from '@playwright/test';
|
||||
|
||||
export class MenuManagementPage {
|
||||
readonly page: Page;
|
||||
@@ -24,8 +24,24 @@ export class MenuManagementPage {
|
||||
}
|
||||
|
||||
async goto() {
|
||||
await this.page.goto('/menus');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
try {
|
||||
console.log('导航到菜单管理页面...');
|
||||
await this.page.goto('/menus');
|
||||
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
|
||||
await this.page.waitForSelector('.el-tree', { timeout: 10000 }).catch(() => {
|
||||
return this.page.waitForSelector('.el-table', { timeout: 5000 });
|
||||
});
|
||||
|
||||
await expect(this.page).toHaveURL(/.*menus/);
|
||||
|
||||
console.log('菜单管理页面加载完成');
|
||||
} catch (error) {
|
||||
await this.page.screenshot({ path: `test-results/menu-management-error-${Date.now()}.png` });
|
||||
console.error('导航到菜单管理页面失败:', error);
|
||||
throw new Error(`导航到菜单管理页面失败: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async clickCreateMenu() {
|
||||
|
||||
Reference in New Issue
Block a user