classroom.page.ts 845 B

123456789101112131415161718192021222324252627282930
  1. import type { Page, Locator } from '@playwright/test';
  2. export class ClassroomPage {
  3. readonly page: Page;
  4. readonly loadingText: Locator;
  5. readonly sidebarScenes: Locator;
  6. constructor(page: Page) {
  7. this.page = page;
  8. this.loadingText = page.getByText('Loading classroom...');
  9. this.sidebarScenes = page.locator('[data-testid="scene-item"]');
  10. }
  11. async goto(stageId: string) {
  12. await this.page.goto(`/classroom/${stageId}`);
  13. }
  14. async waitForLoaded() {
  15. await this.loadingText.waitFor({ state: 'hidden', timeout: 15_000 });
  16. }
  17. async clickScene(index: number) {
  18. await this.sidebarScenes.nth(index).click();
  19. }
  20. /** Get scene title — it's the second span (first is the number badge) */
  21. getSceneTitle(index: number) {
  22. return this.sidebarScenes.nth(index).locator('[data-testid="scene-title"]');
  23. }
  24. }