javascript - Unable to upload file(ng-file upload) in firefox browser with protractor? -


i working on test automation of angular app using protractor+jasmine, , used ng-file uploader upload files in our app. automation script uploads file in chrome browser not working in firefox browser , getting following error :

message: failed: element not visible , may not interacted with

stack: elementnotvisibleerror: element not visible , may not interacted

code snippet file upload

this.uploadfile = function (uploadfile) {     var filetoupload = uploadfile;     var absolutepath = path.resolve(__dirname, filetoupload);     $('input[type="file"]').sendkeys(absolutepath);     element(submitbtn).click(); };  <label style="visibility: hidden; position: absolute; overflow: hidden; width: 0px; height: 0px; border: medium none; margin: 0px; padding: 0px;" tabindex="-1"> upload <input id="ngf-{{ id }}" type="file" ngf-change="onchange($file)" ngf-keep="{{ keep }}" required="required" ngf-validate="{{ validate }}" ngf-pattern="{{ pattern }}" ngf-accept="{{ allowedmime }}" ngf-multiple="{{ multipleallowed }}" ngf-model-invalid="invalid" ng-model-options="{ allowinvalid: multipleallowed }" ng-model="files" ngf-select="" ngf-drop="" name="{{ name }}" accept=".csv,text/plain,application/vnd.ms-excel"/> 

any appreciated!!

woohoo..!! fixed issue , able upload file in firefox browser.

please see code :

this.uploadfile = function (uploadfile) {     if(browser.browsername === 'firefox') {         browser.executeasyncscript(function(callback) {             document.queryselectorall('body>label')[0].setattribute('style', 'position: absolute');             callback();         });     }     var filetoupload = uploadfile;     var absolutepath = path.resolve(__dirname, filetoupload);     $('input[type="file"]').sendkeys(absolutepath);     element(uploadbtn).click(); }; 

and getting browser name, please add following in conf.js file

onprepare: function () {     browser.driver.getcapabilities().then(function(caps){         browser.browsername = caps.get('browsername');     }); } 

also note document.queryselectorall('body>label')[0].setattribute('style', 'position: absolute'); remove attribute in hidden label tag making input tag(child of label tag) visible , set position absolute.

so firefox won't throw error : element not visible , may not interacted with


Comments