getWatchVideoPlayerCurrentTime () {
const elem = $('video')
- if (isIOS()) {
- return elem.getAttribute('currentTime')
- .then(t => parseInt(t, 10))
- .then(t => Math.round(t))
- }
+ const p = isIOS()
+ ? elem.getAttribute('currentTime')
+ : elem.getProperty('currentTime')
- return elem.getProperty('currentTime')
+ return p.then(t => parseInt(t + '', 10))
+ .then(t => Math.ceil(t))
}
waitUntilPlaylistInfo (text: string, maxTime: number) {
return browser.waitUntil(async () => {
+ // Without this we have issues on iphone
+ await $('.video-js').click()
+
return (await $('.video-js .vjs-playlist-info').getText()).includes(text)
}, { timeout: maxTime })
}
})
}
- async playAndPauseVideo (isAutoplay: boolean) {
+ async playAndPauseVideo (isAutoplay: boolean, waitUntilSec: number) {
const videojsElem = () => $('div.video-js')
await videojsElem().waitForExist()
// Autoplay is disabled on iOS and Safari
if (isIOS() || isSafari() || isMobileDevice()) {
- // We can't play the video using protractor if it is not muted
+ // We can't play the video if it is not muted
await browser.execute(`document.querySelector('video').muted = true`)
await this.clickOnPlayButton()
} else if (isAutoplay === false) {
await browserSleep(2000)
await browser.waitUntil(async () => {
- return !await $('.vjs-loading-spinner').isDisplayedInViewport()
- }, { timeout: 20 * 1000 })
-
- await browserSleep(4000)
+ return (await this.getWatchVideoPlayerCurrentTime()) >= waitUntilSec
+ })
await videojsElem().click()
}