]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/e2e/src/po/video-upload.po.ts
Migrate to webdriverio
[github/Chocobozzz/PeerTube.git] / client / e2e / src / po / video-upload.po.ts
index a248912edb55f0b14b7515173e5f14331d617518..34f916b55ee00db75f8eb7eab9d5567b9c34b95f 100644 (file)
@@ -1,33 +1,29 @@
-import { browser, by, element } from 'protractor'
-import { FileDetector } from 'selenium-webdriver/remote'
 import { join } from 'path'
 
 export class VideoUploadPage {
   async navigateTo () {
-    await element(by.css('.header .publish-button')).click()
+    await $('.header .publish-button').click()
 
-    return browser.wait(browser.ExpectedConditions.visibilityOf(element(by.css('.upload-video-container'))))
+    await $('.upload-video-container').waitForDisplayed()
   }
 
   async uploadVideo () {
-    browser.setFileDetector(new FileDetector())
-
     const fileToUpload = join(__dirname, '../../fixtures/video.mp4')
     const fileInputSelector = '.upload-video-container input[type=file]'
     const parentFileInput = '.upload-video-container .button-file'
 
     // Avoid sending keys on non visible element
-    await browser.executeScript(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
-    await browser.executeScript(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
+    await browser.execute(`document.querySelector('${fileInputSelector}').style.opacity = 1`)
+    await browser.execute(`document.querySelector('${parentFileInput}').style.overflow = 'initial'`)
 
-    await browser.sleep(1000)
+    await browser.pause(1000)
 
-    const elem = element(by.css(fileInputSelector))
-    await elem.sendKeys(fileToUpload)
+    const elem = await $(fileInputSelector)
+    await elem.chooseFile(fileToUpload)
 
     // Wait for the upload to finish
-    await browser.wait(async () => {
-      const actionButton = this.getSecondStepSubmitButton().element(by.css('.action-button'))
+    await browser.waitUntil(async () => {
+      const actionButton = this.getSecondStepSubmitButton().$('.action-button')
 
       const klass = await actionButton.getAttribute('class')
       return !klass.includes('disabled')
@@ -35,16 +31,18 @@ export class VideoUploadPage {
   }
 
   async validSecondUploadStep (videoName: string) {
-    const nameInput = element(by.css('input#name'))
-    await nameInput.clear()
-    await nameInput.sendKeys(videoName)
+    const nameInput = $('input#name')
+    await nameInput.clearValue()
+    await nameInput.setValue(videoName)
 
     await this.getSecondStepSubmitButton().click()
 
-    return browser.wait(browser.ExpectedConditions.urlContains('/w/'))
+    return browser.waitUntil(async () => {
+      return (await browser.getUrl()).includes('/w/')
+    })
   }
 
   private getSecondStepSubmitButton () {
-    return element(by.css('.submit-container my-button'))
+    return $('.submit-container my-button')
   }
 }