Search code examples
angularjsprotractorng-file-upload

File size of 0 when trying to upload file through selenium with ng-file-upload


I'm using version 12.01 of the excellent ng-file-upload and attempting to create an e2e test with protractor using Chrome 49. I'm using sendKeys to path the file path, and I'm able to see the upload being triggered, but the file size in the

<button
        class="avatar-upload__button"
        ngf-select="uploadFiles($file, $invalidFiles)"
        ng-model='ngfFile'
        accept="image/*"
        ngf-max-size="14.5MB">
</button>

I'm able to see the file upload being called in this function:

$scope.uploadFiles = (file, errFiles) => {
}

But at this point file.size is 0, where when I run this manually, i get the correct size. I wouldn't be too fussed about this except that the upload seems to be getting choked off/is not happening (presumably because the file information is bad).

My guess at this point is it is related to using this on a button rather than an input[type="file"]. I'm going to start digging into ng-file-upload, but any suggestions/ideas appreciated.


Solution

  • I knew something smelled bad here because nobody else was having this problem. I assembled the path incorrectly and the file did not exist.