Files
his/openhis-ui-vue3/tests/e2e/pages/LoginPage.ts
zhangfei 34ba7cae6a fix: 修复Playwright页面对象定义错误 + 根目录config
- 修复LoginPage/SurgeryBillingPage/DoctorStationPage中page变量作用域问题
- 新增根目录playwright.config.ts(解决配置加载问题)
- .gitignore添加test-results和report目录排除
2026-04-25 22:14:19 +08:00

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();
}
}