]>
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 | |
3419e0e1 C |
8 | if (isIOS()) { |
9 | return elem.getAttribute('currentTime') | |
10 | .then(t => parseInt(t, 10)) | |
11 | .then(t => Math.round(t)) | |
12 | } | |
7f90579c | 13 | |
3419e0e1 C |
14 | return elem.getProperty('currentTime') |
15 | } | |
7f90579c | 16 | |
3419e0e1 C |
17 | waitUntilPlaylistInfo (text: string, maxTime: number) { |
18 | return browser.waitUntil(async () => { | |
19 | return (await $('.video-js .vjs-playlist-info').getText()).includes(text) | |
20 | }, { timeout: maxTime }) | |
7f90579c C |
21 | } |
22 | ||
6b88559b | 23 | waitUntilPlayerWrapper () { |
3419e0e1 C |
24 | return browser.waitUntil(async () => { |
25 | return !!(await $('#placeholder-preview')) | |
26 | }) | |
6b88559b C |
27 | } |
28 | ||
7f90579c | 29 | async playAndPauseVideo (isAutoplay: boolean) { |
3419e0e1 C |
30 | const videojsElem = () => $('div.video-js') |
31 | ||
32 | await videojsElem().waitForExist() | |
c8bc2a1a C |
33 | |
34 | // Autoplay is disabled on iOS and Safari | |
3419e0e1 | 35 | if (isIOS() || isSafari() || isMobileDevice()) { |
c8bc2a1a | 36 | // We can't play the video using protractor if it is not muted |
3419e0e1 | 37 | await browser.execute(`document.querySelector('video').muted = true`) |
c8bc2a1a C |
38 | await this.clickOnPlayButton() |
39 | } else if (isAutoplay === false) { | |
7f90579c C |
40 | await this.clickOnPlayButton() |
41 | } | |
42 | ||
43 | await browserSleep(2000) | |
7f90579c | 44 | |
3419e0e1 C |
45 | await browser.waitUntil(async () => { |
46 | return !await $('.vjs-loading-spinner').isDisplayedInViewport() | |
47 | }, { timeout: 20 * 1000 }) | |
7f90579c | 48 | |
3419e0e1 C |
49 | await browserSleep(4000) |
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 | } |