1 import { join } from 'path'
3 export class VideoUploadPage {
5 await $('.header .publish-button').click()
7 await $('.upload-video-container').waitForDisplayed()
10 async uploadVideo () {
11 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
12 const fileInputSelector = '.upload-video-container input[type=file]'
13 const parentFileInput = '.upload-video-container .button-file'
15 // Avoid sending keys on non visible element
16 await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
17 await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
19 await browser.pause(1000)
21 const elem = await $(fileInputSelector)
22 await elem.chooseFile(fileToUpload)
24 // Wait for the upload to finish
25 await browser.waitUntil(async () => {
26 const actionButton = this.getSecondStepSubmitButton().$('.action-button')
28 const klass = await actionButton.getAttribute('class')
29 return !klass.includes('disabled')
33 async validSecondUploadStep (videoName: string) {
34 const nameInput = $('input#name')
35 await nameInput.clearValue()
36 await nameInput.setValue(videoName)
38 await this.getSecondStepSubmitButton().click()
40 return browser.waitUntil(async () => {
41 return (await browser.getUrl()).includes('/w/')
45 private getSecondStepSubmitButton () {
46 return $('.submit-container my-button')