I have a web site written in Angular and I'm trying to do end-to-end testing using Protractor. The website has a "add button", that opens "choose file dialog box". I want to be able add a file from protractor, but it doesn't upload the file or closes the dialog box.
I tried to create a .exe
file that controls the dialog box via (autoIt) and it works fine (when the dialog box pop up i run the .exe
and everything is working fine). However, I don't understand how to tell the protractor to launch an .exe
after the dialog box appears.
var path = require('path');
it('should upload a file', function() {
var fileToUpload = '...\folder\xxx.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
$('#uploadButton').click();
$('input[type="file"]').sendKeys(absolutePath);
});
var exec = require('child_process').execFile;
var fun = function() {
console.log("fun() start");
exec('c:\\Upload_Nonce.exe', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();