1 import { browser, by, element } from 'protractor'
2 import { FileDetector } from 'selenium-webdriver/remote'
3 import { join } from 'path'
5 export class VideoUploadPage {
7 await element(by.css('.header .upload-button')).click()
9 return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
12 async uploadVideo () {
13 browser.setFileDetector(new FileDetector())
15 const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
16 const fileInputSelector = '.upload-video-container input[type=file]'
17 const parentFileInput = '.upload-video .button-file'
19 // Avoid sending keys on non visible element
20 await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
21 // await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
22 await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
24 const elem = element(by.css(fileInputSelector))
25 await elem.sendKeys(fileToUpload)
27 // Wait for the upload to finish
28 await browser.wait(browser.ExpectedConditions.elementToBeClickable(this.getSecondStepSubmitButton()))
31 async validSecondUploadStep (videoName: string) {
32 const nameInput = element(by.css('input#name'))
33 await nameInput.clear()
34 await nameInput.sendKeys(videoName)
36 await this.getSecondStepSubmitButton().click()
38 return browser.wait(browser.ExpectedConditions.urlContains('/watch/'))
41 private getSecondStepSubmitButton () {
42 return element(by.css('.submit-button:not(.disabled) input'))