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 { return this.table.locator('tbody tr').count(); } async containsText(text: string): Promise { return this.table.getByText(text).count() > 0; } async reload() { await this.refreshButton.click(); await this.page.waitForLoadState('networkidle'); } }