增加 后端,后台管理系统,uniapp会员端的自动化测试。
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user