From d1bd87e066633b8a66266b280327ec828980916b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 May 2018 16:02:29 +0200 Subject: Make it works with new autoplay policy --- client/e2e/src/po/video-watch.po.ts | 49 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'client/e2e/src/po/video-watch.po.ts') diff --git a/client/e2e/src/po/video-watch.po.ts b/client/e2e/src/po/video-watch.po.ts index 0f37e3e33..19d02ff51 100644 --- a/client/e2e/src/po/video-watch.po.ts +++ b/client/e2e/src/po/video-watch.po.ts @@ -1,7 +1,7 @@ import { by, element, browser } from 'protractor' export class VideoWatchPage { - async goOnVideosList (isIphoneDevice: boolean) { + async goOnVideosList (isIphoneDevice: boolean, isSafari: boolean) { let url: string if (isIphoneDevice === true) { @@ -12,11 +12,16 @@ export class VideoWatchPage { } await browser.get(url) - return browser.wait(browser.ExpectedConditions.elementToBeClickable(element(this.getFirstVideoListSelector()))) + + // Waiting the following element does not work on Safari... + if (isSafari === true) return browser.sleep(3000) + + const elem = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() + return browser.wait(browser.ExpectedConditions.visibilityOf(elem)) } getVideosListName () { - return element.all(this.getFirstVideoListSelector()) + return element.all(by.css('.videos .video-miniature .video-miniature-name')) .getText() .then((texts: any) => texts.map(t => t.trim())) } @@ -33,19 +38,19 @@ export class VideoWatchPage { .then(seconds => parseInt(seconds, 10)) } - async pauseVideo (pauseAfterMs: number, isMobileDevice: boolean, isIphoneDevice: boolean) { - if (isMobileDevice === true) { - if (isIphoneDevice === false) { - const playButton = element(by.css('.vjs-big-play-button')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) - await playButton.click() - } else { - const playButton = element(by.css('video')) - await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) - await playButton.click() - } + async pauseVideo (pauseAfterMs: number, isAutoplay: boolean, isSafari: boolean) { + if (isAutoplay === false) { + const playButton = element(by.css('.vjs-big-play-button')) + await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) + await playButton.click() + } + + if (isSafari === true) { + await browser.sleep(1000) + await element(by.css('.vjs-play-control')).click() } + await browser.sleep(1000) await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) const el = element(by.css('div.video-js')) @@ -53,11 +58,7 @@ export class VideoWatchPage { await browser.sleep(pauseAfterMs) - if (isIphoneDevice === true) { - // document.webkitCancelFullScreen() - } else { - return el.click() - } + return el.click() } async clickOnVideo (videoName: string) { @@ -69,7 +70,7 @@ export class VideoWatchPage { } async clickOnFirstVideo () { - const video = element(by.css('.videos .video-miniature:first-child .video-miniature-name')) + const video = element.all(by.css('.videos .video-miniature .video-miniature-name')).first() await browser.wait(browser.ExpectedConditions.elementToBeClickable(video)) const textToReturn = video.getText() @@ -79,7 +80,11 @@ export class VideoWatchPage { return textToReturn } - private getFirstVideoListSelector () { - return by.css('.videos .video-miniature-name') + async goOnAssociatedEmbed () { + let url = await browser.getCurrentUrl() + url = url.replace('/watch/', '/embed/') + url = url.replace(':3333', ':9001') + + return browser.get(url) } } -- cgit v1.2.3