Andrew Mortimer
Andrew Mortimer

Reputation: 172

How do I upload multiple files with 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);

That works fine, for one file. I need to test multiple file uploads. How do I pass multiple files?

Upvotes: 3

Views: 1981

Answers (1)

alecxe
alecxe

Reputation: 473833

Selenium still does not support multiple file uploads:

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

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

Also see:

Upvotes: 7

Related Questions