3

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?

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Andrew Mortimer
  • 172
  • 1
  • 9

1 Answers1

7

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:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195