0

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 the uploadButton.click().
  • this.uploadButton.click().then(function() {this.uploadButton.sendKeys(image_path)}), was worth a shot but nope
  • browser.executeScript('something'); after the click; I forget what the something was but it never got to executeScript

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.

Community
  • 1
  • 1
ItsASine
  • 141
  • 1
  • 3
  • 12
  • Is this working on other browsers? – Sakshi Singla May 13 '15 at 10:47
  • @sakshi-singla it works in that Chrome and Firefox don't care that the dialog is open. They run through the entire suite fine in the background with that explorer.exe in the foreground. It's just IE that doesn't like it. – ItsASine May 13 '15 at 13:49
  • I use the fileInputElement.sendKeys(),uploadButtonElement.click() approach and the upload dialog opens and closes on Chrome. Maybe there another issue in your test ? – Max May 24 '15 at 21:10

0 Answers0