-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathautoplayOnScrollPage.ts
More file actions
26 lines (24 loc) · 1.06 KB
/
autoplayOnScrollPage.ts
File metadata and controls
26 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Page } from '@playwright/test';
import { VideoComponent } from '../../components/videoComponent';
import { BasePage } from './BasePage';
const AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR = '//*[@id="player_html5_api"]';
/**
* Video player examples autoplay on scroll page object
*/
export class AutoplayOnScrollPage extends BasePage {
public autoplayOnScrollVideoComponent: VideoComponent;
constructor(page: Page) {
super(page);
this.autoplayOnScrollVideoComponent = new VideoComponent(page, AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR);
}
/**
* Scrolls the page until the video element is visible using scrollIntoViewIfNeeded method.
* This action ensures the autoplay behavior is triggered when the video comes into view.
* It waits briefly after scrolling to give the video enough time to load and trigger autoplay.
*/
async scrollToVideoElement() {
await this.page.locator(AUTOPLAY_ON_SCROLL_PAGE_VIDEO_SELECTOR).scrollIntoViewIfNeeded();
// Wait briefly to give time for the autoplay to apply
await this.page.waitForTimeout(1000);
}
}