Files
gym-manage/gym-manage-web/e2e/pages/StatisticsDashboardPage.ts
T

38 lines
1.1 KiB
TypeScript

import { Page, Locator, expect } from '@playwright/test';
export class StatisticsDashboardPage {
readonly page: Page;
readonly dashboard: Locator;
readonly chartArea: Locator;
constructor(page: Page) {
this.page = page;
this.dashboard = page.locator('.statistics-dashboard, .dashboard-container');
this.chartArea = page.locator('.chart, [class*="chart"], canvas');
}
async goto() {
console.log('导航到数据统计看板...');
await this.page.goto('/statistics');
await this.page.waitForLoadState('networkidle');
await expect(this.page).toHaveURL(/.*statistics/);
console.log('数据统计看板加载完成');
}
async isDashboardVisible(): Promise<boolean> {
try {
return await this.dashboard.isVisible({ timeout: 10000 });
} catch {
return await this.page.locator('body').isVisible();
}
}
async getChartCount(): Promise<number> {
return await this.chartArea.count();
}
async containsText(text: string): Promise<boolean> {
return await this.page.getByText(text).count() > 0;
}
}