1

How to upload a file in wdio?

The element that allows you to select a file to upload (the normal way) is just an 'Upload File' clickable link.

enter image description here

Source:

<a href="javascript:void(0)" id="fileupload1" name="DocumentCreatedFileId" 
ng-hide="Model.Uploading" pl-upload="" pl-progress-model="Model.Percent" 
pl-auto-upload="true" ng-disabled="disabled" pl-files-model="Model.Files" 
pl-filters-model="filter" on-file-added="Uploading(true)" 
on-file-uploaded="Uploading(false)" class="ng-binding ng-isolate-scope" 
pl-max-file-size="20mb" pl-url="/api/storage/upload" 
pl-flash-swf-url="/content/moxie.swf" 
pl-silverlight-xap-url="/content/moxie.xap">Upload File</a>

I've tried browser.chooseFile(documentsAddPage.uploadFile, 'X.png');, but I get the webdriver.io's favourite error - selector needs to be typeof 'string'

The documentsAddPage.uploadFile is { get: function () { return browser.element('#fileupload1'); } },

Alichino
  • 1,668
  • 2
  • 16
  • 25

1 Answers1

0

OK, it turns out that the special needs child, that is node.js+webdriverIO, can deal with AutoIT scripts.

Use this code, that I copied from here, to run .exe files.

var fun = function() {
  console.log("rrrr");
  exec('CALL hai.exe', function(err, data) {

console.log(err)
console.log(data.toString());
  });
}
fun();
Community
  • 1
  • 1
Alichino
  • 1,668
  • 2
  • 16
  • 25