- 修复LoginPage/SurgeryBillingPage/DoctorStationPage中page变量作用域问题 - 新增根目录playwright.config.ts(解决配置加载问题) - .gitignore添加test-results和report目录排除
34 lines
1002 B
TypeScript
34 lines
1002 B
TypeScript
import { Page, expect } from '@playwright/test';
|
|
|
|
export class LoginPage {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/');
|
|
await this.page.waitForLoadState('domcontentloaded');
|
|
}
|
|
|
|
async login(username: string, password: string) {
|
|
await this.page.fill('input[placeholder*="用户名"], input[placeholder*="账号"]', username);
|
|
await this.page.fill('input[placeholder*="密码"]', password);
|
|
await this.page.click('button:has-text("登录")');
|
|
await this.page.waitForLoadState('networkidle');
|
|
}
|
|
|
|
async expectLoginSuccess() {
|
|
await expect(this.page).toHaveURL(/.*(dashboard|home|index).*/, { timeout: 15000 });
|
|
}
|
|
|
|
async expectLoginFailed() {
|
|
await expect(this.page.locator('.el-message--error')).toBeVisible({ timeout: 5000 });
|
|
}
|
|
|
|
async expectOnLoginPage() {
|
|
await expect(this.page.locator('input[placeholder*="用户名"], input[placeholder*="账号"]')).toBeVisible();
|
|
}
|
|
}
|