diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-30 16:24:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-09-01 15:06:46 +0200 |
commit | 3419e0e1fe8e48a08b63ca0ded31087f913eb2b6 (patch) | |
tree | 63ac7190b79194e93aec9bbfd3c336e60f469e9d /client/e2e/src/po/player.po.ts | |
parent | 2a4c9669d2d6ac6cd4ae43544698f826ae98080f (diff) | |
download | PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.gz PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.tar.zst PeerTube-3419e0e1fe8e48a08b63ca0ded31087f913eb2b6.zip |
Migrate to webdriverio
Diffstat (limited to 'client/e2e/src/po/player.po.ts')
-rw-r--r-- | client/e2e/src/po/player.po.ts | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.ts index cb148a003..9d6e21009 100644 --- a/client/e2e/src/po/player.po.ts +++ b/client/e2e/src/po/player.po.ts | |||
@@ -1,45 +1,54 @@ | |||
1 | import { browser, by, element } from 'protractor' | ||
2 | import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils' | 1 | import { browserSleep, isIOS, isMobileDevice, isSafari } from '../utils' |
3 | 2 | ||
4 | export class PlayerPage { | 3 | export class PlayerPage { |
5 | 4 | ||
6 | async getWatchVideoPlayerCurrentTime () { | 5 | getWatchVideoPlayerCurrentTime () { |
7 | const elem = element(by.css('video')) | 6 | const elem = $('video') |
8 | 7 | ||
9 | return elem.getAttribute('currentTime') | 8 | if (isIOS()) { |
10 | } | 9 | return elem.getAttribute('currentTime') |
10 | .then(t => parseInt(t, 10)) | ||
11 | .then(t => Math.round(t)) | ||
12 | } | ||
11 | 13 | ||
12 | waitUntilPlaylistInfo (text: string) { | 14 | return elem.getProperty('currentTime') |
13 | const elem = element(by.css('.video-js .vjs-playlist-info')) | 15 | } |
14 | 16 | ||
15 | return browser.wait(browser.ExpectedConditions.textToBePresentInElement(elem, text)) | 17 | waitUntilPlaylistInfo (text: string, maxTime: number) { |
18 | return browser.waitUntil(async () => { | ||
19 | return (await $('.video-js .vjs-playlist-info').getText()).includes(text) | ||
20 | }, { timeout: maxTime }) | ||
16 | } | 21 | } |
17 | 22 | ||
18 | waitUntilPlayerWrapper () { | 23 | waitUntilPlayerWrapper () { |
19 | const elem = element(by.css('#placeholder-preview')) | 24 | return browser.waitUntil(async () => { |
20 | 25 | return !!(await $('#placeholder-preview')) | |
21 | return browser.wait(browser.ExpectedConditions.presenceOf(elem)) | 26 | }) |
22 | } | 27 | } |
23 | 28 | ||
24 | async playAndPauseVideo (isAutoplay: boolean) { | 29 | async playAndPauseVideo (isAutoplay: boolean) { |
25 | const videojsEl = element(by.css('div.video-js')) | 30 | const videojsElem = () => $('div.video-js') |
26 | await browser.wait(browser.ExpectedConditions.elementToBeClickable(videojsEl)) | 31 | |
32 | await videojsElem().waitForExist() | ||
27 | 33 | ||
28 | // Autoplay is disabled on iOS and Safari | 34 | // Autoplay is disabled on iOS and Safari |
29 | if (await isIOS() || await isSafari() || await isMobileDevice()) { | 35 | if (isIOS() || isSafari() || isMobileDevice()) { |
30 | // We can't play the video using protractor if it is not muted | 36 | // We can't play the video using protractor if it is not muted |
31 | await browser.executeScript(`document.querySelector('video').muted = true`) | 37 | await browser.execute(`document.querySelector('video').muted = true`) |
32 | await this.clickOnPlayButton() | 38 | await this.clickOnPlayButton() |
33 | } else if (isAutoplay === false) { | 39 | } else if (isAutoplay === false) { |
34 | await this.clickOnPlayButton() | 40 | await this.clickOnPlayButton() |
35 | } | 41 | } |
36 | 42 | ||
37 | await browserSleep(2000) | 43 | await browserSleep(2000) |
38 | await browser.wait(browser.ExpectedConditions.invisibilityOf(element(by.css('.vjs-loading-spinner')))) | ||
39 | 44 | ||
40 | await browserSleep(2000) | 45 | await browser.waitUntil(async () => { |
46 | return !await $('.vjs-loading-spinner').isDisplayedInViewport() | ||
47 | }, { timeout: 20 * 1000 }) | ||
41 | 48 | ||
42 | await videojsEl.click() | 49 | await browserSleep(4000) |
50 | |||
51 | await videojsElem().click() | ||
43 | } | 52 | } |
44 | 53 | ||
45 | async playVideo () { | 54 | async playVideo () { |
@@ -47,8 +56,9 @@ export class PlayerPage { | |||
47 | } | 56 | } |
48 | 57 | ||
49 | private async clickOnPlayButton () { | 58 | private async clickOnPlayButton () { |
50 | const playButton = element(by.css('.vjs-big-play-button')) | 59 | const playButton = () => $('.vjs-big-play-button') |
51 | await browser.wait(browser.ExpectedConditions.elementToBeClickable(playButton)) | 60 | |
52 | await playButton.click() | 61 | await playButton().waitForClickable() |
62 | await playButton().click() | ||
53 | } | 63 | } |
54 | } | 64 | } |