angularjs - Protractor - How to upload file using ng-file-upload in test case without changing code? -
i using https://github.com/danialfarid/ng-file-upload file upload. have test wrote protractor test case not working.
code
<div class="col-lg-12 up-buttons"> <div ng-file-select="" ng-model="files" ng-model-rejected="rejfiles" class="btn btn-default" ng-multiple="false" ng-accept="'text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'" ng-model-rejected="rejfiles" tabindex="0">choose file</div> </div>
test case
it('upload file', function(){ var filetoupload = 'c:/users/anusha/desktop/demo.csv'; var absolutepath = path.resolve(filetoupload); $('input[type="file"]').sendkeys(absolutepath); browser.sleep(1500); })
i can upload file received in rejfiles model instead of files model eventhough file format correct one. please suggest me how this?
html
<div class="col-lg-12 up-buttons"> <div ng-file-select="" ng-model="files" ng-model-rejected="rejfiles" class="btn btn-default" ng-multiple="false" ng-accept="'*.csv'" ng-model-rejected="rejfiles" tabindex="0">choose file</div> </div>
test case
var path = require('path'); var filetoupload = file_path; var absolutepath = path.resolve(filetoupload); element.all(by.css('input[type="file"]')).then(function(items) { items[0].sendkeys(absolutepath); }); browser.sleep(500);
Comments
Post a Comment