bd21e2d1f7
- 更新 Page Object 模型适配新字段名 - 新增 UAT 测试套件与 journey 测试用例 - 优化测试辅助工具与数据工厂 - 更新 playwright 认证状态
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { Page, Locator, expect } from '@playwright/test';
|
|
|
|
export class ExceptionLogPage {
|
|
readonly page: Page;
|
|
readonly table: Locator;
|
|
readonly searchInput: Locator;
|
|
readonly refreshButton: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.table = page.locator('.ant-table').first();
|
|
this.searchInput = page.getByPlaceholder('搜索路径/异常信息');
|
|
this.refreshButton = page.getByRole('button', { name: '刷新' });
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/exceptionlog');
|
|
await this.page.waitForLoadState('networkidle');
|
|
await this.table.waitFor({ state: 'visible', timeout: 15000 }).catch(() => {});
|
|
await expect(this.page).toHaveURL(/.*exceptionlog/);
|
|
}
|
|
|
|
async search(keyword: string) {
|
|
await this.searchInput.fill(keyword);
|
|
await this.searchInput.press('Enter');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async clearSearch() {
|
|
await this.searchInput.clear();
|
|
await this.searchInput.press('Enter');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async getTableRowCount(): Promise<number> {
|
|
return this.table.locator('tbody tr').count();
|
|
}
|
|
|
|
async containsText(text: string): Promise<boolean> {
|
|
return this.table.getByText(text).count() > 0;
|
|
}
|
|
|
|
async reload() {
|
|
await this.refreshButton.click();
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
}
|