first commit

This commit is contained in:
2025-11-04 16:29:07 +08:00
commit 8ee74625c7
19 changed files with 4562 additions and 0 deletions

50
pages/LoginPage.ts Normal file
View File

@ -0,0 +1,50 @@
/**
* 登录页面对象
* 封装登录相关的操作
*/
import { Page, expect } from '@playwright/test';
import { BasePage } from './BasePage';
export class LoginPage extends BasePage {
constructor(page: Page) {
super(page);
}
/**
* 访问首页
*/
async visitHomePage(): Promise<void> {
await this.goto(this.config.env.baseUrl);
await expect(this.page.getByRole('button', { name: 'Log in' })).toBeVisible();
}
/**
* 点击登录按钮
*/
async clickLoginButton(): Promise<void> {
await this.page.getByRole('button', { name: 'Log in' }).click();
await expect(this.page.getByRole('textbox', { name: 'Email Address' })).toBeVisible();
}
/**
* 输入登录凭证并登录
*/
async login(email: string, password: string): Promise<void> {
await this.page.getByRole('textbox', { name: 'Email Address' }).click();
await this.page.getByRole('textbox', { name: 'Email Address' }).fill(email);
await this.page.getByRole('textbox', { name: 'Psssword' }).click();
await this.page.getByRole('textbox', { name: 'Psssword' }).fill(password);
await this.page.getByRole('button', { name: 'Log in' }).click();
await expect(this.page.getByRole('link').filter({ hasText: '学生工作台' })).toBeVisible();
}
/**
* 完整登录流程
*/
async performLogin(): Promise<void> {
await this.visitHomePage();
await this.clickLoginButton();
await this.login(this.config.credentials.email, this.config.credentials.password);
}
}