1

i'm trying to simulate an upload file with protractor i know that the protractor can't interact with OS window and i created an EXE file (with autoit), that takes focus and insert a file . when i'm testing manually everything working ok . when i try to write it in protractor i get error

this is my protractor code ( using child_process ) -- see pic

Code

Here is my error massage

error

tried using : NO LUCK!! upload metod2

Oded Kessler
  • 131
  • 2
  • 2
  • 12
  • Are you sure you need AutoIT to upload a file in the first place? There is a simpler way - send the path directly to your file input. – alecxe Apr 03 '16 at 13:20
  • @alecxe how do I do that ? , and how do I see that the file is really uploaded? – Oded Kessler Apr 03 '16 at 14:00
  • 1
    Sure, see http://stackoverflow.com/questions/21305298/how-to-upload-file-in-angularjs-e2e-protractor-testing. – alecxe Apr 03 '16 at 14:01
  • @alecxe hey it doesn't work can I write you on private ? – Oded Kessler Apr 03 '16 at 14:10
  • It will have a hidden input box. Identify input box and use sendKeys to send the file path. If not try this: Where you are trying to upload i see a empty array in "execFile" it should have the window title, for firefox it will have "File Upload" and for chrome "Open" – Nick Apr 05 '16 at 07:10
  • Do not add 'it' inside another 'it'. 'it' is for test case, that might be reason of failures – Xotabu4 Apr 05 '16 at 14:13
  • Thanks guys but I don't understand , would it more clear if I upload my html and css elements. Can someone help me in private my mail is odedkessler@gmail.com. I use chrome and I can't upload a file . – Oded Kessler Apr 05 '16 at 16:31
  • Can someone send me a web page that I can practice ? Maybe the html file that in using is not good – Oded Kessler Apr 05 '16 at 17:12

2 Answers2

0

You don't need AutoIT to upload files. Just send full absolute path to file that you want to upload into upload input. If you are running tests with Selenium Grid you also need to use FileDetector to send file to node where test is running:

var FileDetector = require('selenium-webdriver/remote/index.js').FileDetector;
browser.setFileDetector(new FileDetector());

var path = require('path');

var fileToUpload = '../yourfile.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
$('hiddenfileuploadinput').sendKeys(absolutePath)

Here is question that has answers that might help: How to upload file in angularjs e2e protractor testing

Community
  • 1
  • 1
Xotabu4
  • 3,063
  • 17
  • 29
0

I have faced the same error while working on mine. I had to open a .exe file using protractor. Putting the right path to .exe worked for me. Can you also re-check if it's the right path

sindhu
  • 11
  • 2