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

64
pages/StudentPage.ts Normal file
View File

@ -0,0 +1,64 @@
/**
* 学生工作台页面对象
* 封装学生管理相关的操作
*/
import { Page, expect } from '@playwright/test';
import { BasePage } from './BasePage';
export interface StudentData {
name: string;
branchText: RegExp;
branchValue: RegExp;
counselorEmail: RegExp;
contractCategory: string;
contractName: string;
}
export class StudentPage extends BasePage {
constructor(page: Page) {
super(page);
}
/**
* 返回学生工作台
*/
async goToStudentWorkbench(): Promise<void> {
await this.page.getByRole('link').filter({ hasText: '学生工作台' }).click();
await expect(this.page.getByText('Student Name')).toBeVisible();
}
/**
* 创建新学生
*/
async createNewStudent(studentData: StudentData): Promise<void> {
await this.page.getByRole('button', { name: 'New Student' }).click();
// 填写学生名称
await this.page.getByRole('textbox', { name: 'Name *', exact: true }).click();
await this.page.getByRole('textbox', { name: 'Name *', exact: true }).fill(studentData.name);
// 选择分公司
await this.page.locator('div').filter({ hasText: studentData.branchText }).nth(2).click();
await this.page.locator('div').filter({ hasText: studentData.branchValue }).nth(1).click();
// 选择顾问
await this.page.getByText('Select counselor').click();
await this.page.locator('div').filter({ hasText: studentData.counselorEmail }).nth(1).click();
// 点击日期选择器关闭按钮
await this.page.locator('svg').nth(5).click();
// 填写合同信息
await this.page.getByRole('textbox', { name: 'Contract Category *' }).click();
await this.page.getByRole('textbox', { name: 'Contract Category *' }).fill(studentData.contractCategory);
await this.page.getByRole('textbox', { name: 'Contract Name *' }).click();
await this.page.getByRole('textbox', { name: 'Contract Name *' }).fill(studentData.contractName);
// 确认创建
await this.page.getByRole('button', { name: 'Confirm' }).click();
// 验证学生创建成功
await expect(this.page.getByText(studentData.name).first()).toBeVisible();
}
}