Files
openmaic/OpenMAIC/e2e/pages/home.page.ts
2026-08-16 14:58:47 +08:00

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