]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/player.po.ts
Add build-essentials if architecture not supported
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / player.po.ts
CommitLineData
c8bc2a1a
C
1import { browser, by, element } from 'protractor'
2import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils'
7f90579c
C
3
4export 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
6b88559b 19 waitUntilPlayerWrapper () {
15feebd9 20 const elem = element(by.css('#placeholder-preview'))
6b88559b
C
21
22 return browser.wait(browser.ExpectedConditions.presenceOf(elem))
23 }
24
7f90579c 25 async playAndPauseVideo (isAutoplay: boolean) {
c8bc2a1a
C
26 const videojsEl = element(by.css('div.video-js'))
27 await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
28
29 // Autoplay is disabled on iOS and Safari
30 if (await isIOS() || await isSafari() || await isMobileDevice()) {
31 // We can't play the video using protractor if it is not muted
32 await browser.executeScript(`document.querySelector('video').muted = true`)
33 await this.clickOnPlayButton()
34 } else if (isAutoplay === false) {
7f90579c
C
35 await this.clickOnPlayButton()
36 }
37
38 await browserSleep(2000)
39 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
40
c8bc2a1a 41 await browserSleep(2000)
7f90579c
C
42
43 await videojsEl.click()
44 }
45
46 async playVideo () {
47 return this.clickOnPlayButton()
48 }
49
50 private async clickOnPlayButton () {
51 const playButton = element(by.css('.vjs-big-play-button'))
52 await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton))
53 await playButton.click()
54 }
55}