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?
Selenium still does not support multiple file uploads:
Support <input type=file multiple>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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With