We are using ngFlow to do file uploads in our application. We use protractor for our testing. We have multiple test case conditions to be tested like file format not supported, max size etc. What is the best way to select files using protractor? We are able to click the button to upload the file, but we don't have any control on the system file explorer. We are able to send keys to input type file but we don't know how to call submit on that as we are not a button inside of a form/ using a form.
You need to inject the path of your file into your input.
var path = require('path');
it('should upload file', function() {
var fileToUpload = '../path/foo.txt',
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
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