import { Page, Locator, expect } from '@playwright/test'; export class OperationLogPage { readonly page: Page; readonly searchInput: Locator; readonly refreshButton: Locator; readonly table: Locator; constructor(page: Page) { this.page = page; this.searchInput = page.getByPlaceholder('搜索操作人/描述'); this.refreshButton = page.getByRole('button', { name: '刷新' }); this.table = page.locator('.ant-table').first(); } async goto() { await this.page.goto('/oplog'); await this.page.waitForLoadState('networkidle'); await this.table.waitFor({ state: 'visible', timeout: 15000 }).catch(() => {}); await expect(this.page).toHaveURL(/.*oplog/); } async searchByKeyword(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'); } }