]>
Commit | Line | Data |
---|---|---|
c8bc2a1a | 1 | import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils' |
7f90579c C |
2 | |
3 | export class PlayerPage { | |
4 | ||
3419e0e1 C |
5 | getWatchVideoPlayerCurrentTime () { |
6 | const elem = $('video') | |
f74832ce | 7 | |
12d6b873 C |
8 | const p = isIOS() |
9 | ? elem.getAttribute('currentTime') | |
10 | : elem.getProperty('currentTime') | |
7f90579c | 11 | |
12d6b873 C |
12 | return p.then(t => parseInt(t + '', 10)) |
13 | .then(t => Math.ceil(t)) | |
3419e0e1 | 14 | } |
7f90579c | 15 | |
3419e0e1 C |
16 | waitUntilPlaylistInfo (text: string, maxTime: number) { |
17 | return browser.waitUntil(async () => { | |
6d210220 C |
18 | // Without this we have issues on iphone |
19 | await $('.video-js').click() | |
20 | ||
3419e0e1 C |
21 | return (await $('.video-js .vjs-playlist-info').getText()).includes(text) |
22 | }, { timeout: maxTime }) | |
7f90579c C |
23 | } |
24 | ||
6b88559b | 25 | waitUntilPlayerWrapper () { |
3419e0e1 C |
26 | return browser.waitUntil(async () => { |
27 | return !!(await $('#placeholder-preview')) | |
28 | }) | |
6b88559b C |
29 | } |
30 | ||
12d6b873 | 31 | async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) { |
3419e0e1 C |
32 | const videojsElem = () => $('div.video-js') |
33 | ||
34 | await videojsElem().waitForExist() | |
c8bc2a1a C |
35 | |
36 | // Autoplay is disabled on iOS and Safari | |
3419e0e1 | 37 | if (isIOS() || isSafari() || isMobileDevice()) { |
afb7d2d5 | 38 | // We can't play the video if it is not muted |
3419e0e1 | 39 | await browser.execute(`document.querySelector('video').muted = true`) |
c8bc2a1a C |
40 | await this.clickOnPlayButton() |
41 | } else if (isAutoplay === false) { | |
7f90579c C |
42 | await this.clickOnPlayButton() |
43 | } | |
44 | ||
45 | await browserSleep(2000) | |
7f90579c | 46 | |
3419e0e1 | 47 | await browser.waitUntil(async () => { |
6d210220 | 48 | return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec |
12d6b873 | 49 | }) |
3419e0e1 C |
50 | |
51 | await videojsElem().click() | |
7f90579c C |
52 | } |
53 | ||
54 | async playVideo () { | |
55 | return this.clickOnPlayButton() | |
56 | } | |
57 | ||
58 | private async clickOnPlayButton () { | |
3419e0e1 C |
59 | const playButton = () => $('.vjs-big-play-button') |
60 | ||
61 | await playButton().waitForClickable() | |
62 | await playButton().click() | |
7f90579c C |
63 | } |
64 | } |