fix(e2e): 修复用户管理测试按钮选择器超时问题
- 优化按钮选择器使用locator API - 增加页面加载等待时间 - 添加错误处理和日志 任务 1/4
This commit is contained in:
@@ -8,15 +8,25 @@ export interface UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class AdminUserPage {
|
export class AdminUserPage {
|
||||||
constructor(private page: Page) {}
|
constructor(private page: Page) { }
|
||||||
|
|
||||||
async goto() {
|
async goto() {
|
||||||
await this.page.goto('/admin/users');
|
await this.page.goto('/admin/users');
|
||||||
await this.page.waitForLoadState('networkidle');
|
await this.page.waitForLoadState('domcontentloaded');
|
||||||
|
await this.page.waitForSelector('table', { timeout: 10000, state: 'visible' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async createUser(data: UserData) {
|
async createUser(data: UserData) {
|
||||||
await this.page.click('button:has-text("新建用户")');
|
await this.goto();
|
||||||
|
|
||||||
|
await this.page.waitForLoadState('domcontentloaded');
|
||||||
|
await this.page.waitForTimeout(1000);
|
||||||
|
|
||||||
|
const addButton = this.page.locator('button:has-text("添加用户")');
|
||||||
|
await addButton.waitFor({ timeout: 10000, state: 'visible' });
|
||||||
|
await addButton.click();
|
||||||
|
|
||||||
|
await this.page.waitForSelector('input[name="email"]', { timeout: 5000, state: 'visible' });
|
||||||
await this.page.fill('input[name="email"]', data.email);
|
await this.page.fill('input[name="email"]', data.email);
|
||||||
await this.page.fill('input[name="password"]', data.password);
|
await this.page.fill('input[name="password"]', data.password);
|
||||||
|
|
||||||
@@ -28,7 +38,7 @@ export class AdminUserPage {
|
|||||||
await this.page.selectOption('select[name="role"]', data.role);
|
await this.page.selectOption('select[name="role"]', data.role);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.page.click('button[type="submit"]');
|
await this.page.click('button:has-text("创建")');
|
||||||
}
|
}
|
||||||
|
|
||||||
async expectUserInList(email: string) {
|
async expectUserInList(email: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user