]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/e2e/src/po/player.po.ts
Merge branch 'release/3.2.0' into develop
[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
f74832ce
C
6 async getWatchVideoPlayerCurrentTime () {
7 const elem = element(by.css('video'))
8
9 return elem.getAttribute('currentTime')
7f90579c
C
10 }
11
12 waitUntilPlaylistInfo (text: string) {
13 const elem = element(by.css('.video-js .vjs-playlist-info'))
14
15 return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, text))
16 }
17
6b88559b 18 waitUntilPlayerWrapper () {
15feebd9 19 const elem = element(by.css('#placeholder-preview'))
6b88559b
C
20
21 return browser.wait(browser.ExpectedConditions.presenceOf(elem))
22 }
23
7f90579c 24 async playAndPauseVideo (isAutoplay: boolean) {
c8bc2a1a
C
25 const videojsEl = element(by.css('div.video-js'))
26 await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl))
27
28 // Autoplay is disabled on iOS and Safari
29 if (await isIOS() || await isSafari() || await isMobileDevice()) {
30 // We can't play the video using protractor if it is not muted
31 await browser.executeScript(`document.querySelector('video').muted = true`)
32 await this.clickOnPlayButton()
33 } else if (isAutoplay === false) {
7f90579c
C
34 await this.clickOnPlayButton()
35 }
36
37 await browserSleep(2000)
38 await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner'))))
39
c8bc2a1a 40 await browserSleep(2000)
7f90579c
C
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}