1

I am trying to upload multiple files to the page with

<input id="dropInput" type="file" multiple>

For one file it is as simple as:

driver.FindElement(By.Id("dropInput")).SendKeys(@"path-to-file");

As a user I can click Choose Files button and select number of files (with Ctrl) so in Open dialog I can see sth like: "file-1" "file-2"

From the script it does not work. I have tried different combinations of SendKeys argument:

  • @"file-1" + " " + @"file-2"
  • @"file-1" + ", " + @"file-2"
  • "\"path\\to\\file-1\" \"path\\to\\file-2\""
  • Path.GetFullPath(file-1) + " " + Path.GetFullPath(file-2)
  • "\"" + Path.GetFullPath(file-1) + "\" \"" + Path.GetFullPath(file-2) + "\""

The input accepts the last file only. The same with sending keys several times. For the last example I have got an exception:

unknown error: path is not absolute: "file-1" "file-2"

I am out of ideas.

I'd like to know if there is any simple solution for that before I'll start injecting jQuery scripts to the page under test.

Please advise.

Cheers, Przemek

Przemek Sech
  • 47
  • 1
  • 1
  • 7
  • The [webdriver:upload multiple files](http://stackoverflow.com/questions/23955430/webdriverupload-multiple-files) post is not an answer for me as for browser limitations but may be helpful for others. – Przemek Sech Feb 08 '16 at 03:57
  • 1
    you can send each file one by one using sendkeys and then click on upload button – Shubham Jain Feb 08 '16 at 05:40
  • @PrzemekSech Did you ever come up with a solution? – Scotty H Aug 23 '17 at 20:41

0 Answers0