]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/e2e/src/po/player.po.ts
Fix e2e tests
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / player.po.ts
1 import { browser, by, element } from 'protractor'
2 import { browserSleep, isIOS, isMobileDevice, isSafari } 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 const videojsEl = element(by.css('div.video-js'))
21 await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
22
23 // Autoplay is disabled on iOS and Safari
24 if (await isIOS() || await isSafari() || await isMobileDevice()) {
25 // We can't play the video using protractor if it is not muted
26 await browser.executeScript(`document.querySelector('video').muted = true`)
27 await this.clickOnPlayButton()
28 } else if (isAutoplay === false) {
29 await this.clickOnPlayButton()
30 }
31
32 await browserSleep(2000)
33 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
34
35 await browserSleep(2000)
36
37 await videojsEl.click()
38 }
39
40 async playVideo () {
41 return this.clickOnPlayButton()
42 }
43
44 private async clickOnPlayButton () {
45 const playButton = element(by.css('.vjs-big-play-button'))
46 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton))
47 await playButton.click()
48 }
49 }