]>
Commit | Line | Data |
---|---|---|
7f90579c C |
1 | import { browser, by, element, ExpectedConditions } from 'protractor' |
2 | import { browserSleep, isIOS, isMobileDevice } from '../utils' | |
3 | ||
4 | export class PlayerPage { | |
5 | ||
6 | getWatchVideoPlayerCurrentTime () { | |
7 | return element(by.css('.video-js .vjs-current-time-display')) | |
8 | .getText() | |
9 | .then((t: string) => t.split(':')[1]) | |
10 | .then(seconds => parseInt(seconds, 10)) | |
11 | } | |
12 | ||
13 | waitUntilPlaylistInfo (text: string) { | |
14 | const elem = element(by.css('.video-js .vjs-playlist-info')) | |
15 | ||
16 | return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, text)) | |
17 | } | |
18 | ||
19 | async playAndPauseVideo (isAutoplay: boolean) { | |
20 | // Autoplay is disabled on iOS | |
21 | if (isAutoplay === false || await isIOS()) { | |
22 | await this.clickOnPlayButton() | |
23 | } | |
24 | ||
25 | await browserSleep(2000) | |
26 | await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) | |
27 | ||
28 | const videojsEl = element(by.css('div.video-js')) | |
29 | await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl)) | |
30 | ||
7f90579c C |
31 | if (await isMobileDevice()) { |
32 | await browserSleep(5000) | |
33 | ||
61c299eb C |
34 | // On Android, we need to click twice on "play" (BrowserStack particularity) |
35 | if (!await isIOS()) await videojsEl.click() | |
7f90579c C |
36 | } |
37 | ||
38 | browser.ignoreSynchronization = false | |
39 | await browserSleep(7000) | |
40 | browser.ignoreSynchronization = true | |
41 | ||
42 | await videojsEl.click() | |
43 | } | |
44 | ||
45 | async playVideo () { | |
46 | return this.clickOnPlayButton() | |
47 | } | |
48 | ||
49 | private async clickOnPlayButton () { | |
50 | const playButton = element(by.css('.vjs-big-play-button')) | |
51 | await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) | |
52 | await playButton.click() | |
53 | } | |
54 | } |