How do I upload multiple files using Protractor?

I am using webdriver.WebElement.sendKeys

and Path to upload a single file. The code looks like this:

var path = require('path'),
  uploadInput = element(by.css("input[type=file]")),
  fileToUpload = "../test_image/download.jpeg",
  absolutePath = path.resolve(__dirname, fileToUpload);

  uploadInput.sendKeys(absolutePath);

      

This works great for a single file. I need to test multiple file uploads. How do I transfer multiple files?

+3


source to share


1 answer


Selenium still doesn't support multiple file uploads:

But according to webdriver: upload multiple files , you should be able to solve it in Chrome by concatenating the file paths with a new -line character:



uploadInput.sendKeys(absolutePath1 + "\n" + absolutePath2);

      

Also see:

+6


source







All Articles