The Code
I have a linear application where halfway through the user must submit images to continue. The submitFile
function is below:
selectFile: function(image) {
var path = require('path');
var image_path = path.resolve(__dirname, image);
this.uploadButton.click();
this.uploadButton.sendKeys(image_path);
}
I know from Selenium that you cannot interact with the OS, just anything contained within the browser. So we've been following the stackoverflow go-to answer for Protractor file uploading.
The Result
The function in practice clicks the file upload button, the dialog box pops up, sendKeys
manually tells it what image to use, then it moves on with its life while that dialog box is always open. Chrome and Firefox don't care that the dialog remains, so I can continue testing pages past image upload without issue.
But today, we're getting into trying to automate IE testing and it seems that that pop up must be dealt with to continue. It never hits this.uploadButton.sendKeys(blah);
. The moment the dialog is opened IE wants it resolved before continuing.
The Attempts
this.uploadButton.sendKeys(protractor.Key.ESCAPE)
right after the click, which didn't work since the test cannot not get past theuploadButton.click()
.this.uploadButton.click().then(function() {this.uploadButton.sendKeys(image_path)})
, was worth a shot but nopebrowser.executeScript('something');
after the click; I forget what the something was but it never got toexecuteScript
The Thoughts
- Is there a way to kill a process from Protractor? To be able to kill explorer.exe / explorer's pid
- Is it possible to have a listener to kill the pop up as it happens?
- Though would any of the above mess with the
sendKeys
? - Does the button click and
sendKeys
even work on IE11?
Right now, I'm just sticking to manual testing for IE, though I'd love to be able to integrate my tests with IE so I can use Browserstack or even just multiCapabilities
in my config.