import { Page, expect } from '@playwright/test'; export class LoginPage { constructor(private page: Page) {} async goto() { await this.page.goto('/'); } async login(username: string, password: string) { await this.page.fill('input[placeholder="请输入用户名"]', username); await this.page.fill('input[placeholder="请输入密码"]', password); await this.page.click('button:has-text("登录")'); } async expectLoginSuccess() { await expect(this.page).toHaveURL(/.*(dashboard|home).*/); } async expectLoginFailed() { await expect(this.page.locator('.el-message--error')).toBeVisible(); } }