0

I am clicking on a upload button which opens up a windows file selector. I am not able to write the path to a file in that File Selector dialog using protractor.

I tried copying the text to the clipboard and pasting the same to File Upload by passing ctrl+v keypress in protractor. Able to copy the text but paste is not working.

Now I have also used robot-js but not helping me Any idea how can we do this in protractor?

enter image description here

simond
  • 684
  • 1
  • 10
  • 36
  • I don't know if libraries for this exist but I would recommend to just simulate the file upload since protractor is made for testing in the browser. => https://stackoverflow.com/questions/21305298/how-to-upload-file-in-angularjs-e2e-protractor-testing just a thought. – Silvan Bregy Jul 25 '18 at 12:26
  • i have already tried this – simond Jul 25 '18 at 13:04
  • The question that Silvan referenced is the only way to upload a file in protractor. If this isn't working for you create a new question with the errors you get from using that method so we can help you with that. – Ben Mohorc Jul 25 '18 at 14:44
  • after this action element(by.css('input[type="file"]')).sendKeys(absolutePath); -it is taking file in input control, but after this action element(by.id('uploadButton')).click(); -it is again opening window file dialog , so i am thinking , how to enter path in opened window dialog and for press enter i have used this browser.actions().sendKeys(protractor.Key.ENTER); – simond Jul 25 '18 at 15:56

1 Answers1

0

Send keys to the input element with your file path, it will do the same flow without opening the windows file pop up

CusHoria
  • 21
  • 4