40 lines
1008 B
TypeScript
40 lines
1008 B
TypeScript
import type { Page, Locator } from '@playwright/test';
|
|
|
|
export class HomePage {
|
|
readonly page: Page;
|
|
readonly logo: Locator;
|
|
readonly textarea: Locator;
|
|
readonly enterButton: Locator;
|
|
readonly interactiveModeButton: Locator;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
this.logo = page.locator('img[alt="麦洛学习"]');
|
|
this.textarea = page.locator('textarea');
|
|
this.enterButton = page.getByRole('button', {
|
|
name: /^(background|foreground|后台生成|前台生成)$/i,
|
|
});
|
|
this.interactiveModeButton = page.getByRole('button', {
|
|
name: /interactive mode|深度交互/i,
|
|
});
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto('/');
|
|
}
|
|
|
|
async fillRequirement(text: string) {
|
|
await this.textarea.fill(text);
|
|
}
|
|
|
|
async submit() {
|
|
await this.enterButton.click();
|
|
}
|
|
|
|
async enableInteractiveMode() {
|
|
if ((await this.interactiveModeButton.getAttribute('aria-pressed')) !== 'true') {
|
|
await this.interactiveModeButton.click();
|
|
}
|
|
}
|
|
}
|