javascript - Protractor - Failed: stale element reference: element is not attached to the page document -


i have function in protractor e2e page object unchecks several options dropdown menu. had worked fine, i'm getting following error:

failed: stale element reference: element not attached page document

i have tried fetching elements on each iteration of loop, loop executes before promise resolved first time, meaning "limit" value x passed repeatedly, , test clicks on same dropdown option several times.

this.uncheckcolumns = function(limit) {     element(by.classname('fa-cog')).click();     element.all(by.classname('multiselectli')).then(function(options) {         (x = 1; x < limit; x++) {             options[x].click();         };     }); }; 

how using each(element, index):

element.all(by.classname('multiselectli')).each(function(option, index) {     if (index < limit) {         option.click();     } }); 

or, in conjunction filter(element, index):

element.all(by.classname('multiselectli')).filter(function(option, index) {     return index < limit; }).each(function(option) {     option.click(); }); 

also, naive approach solve problem (calling element.all() continuously in loop):

for (var index = 0; index < limit; index++) {     var option = element.all(by.classname('multiselectli')).get(index);     option.click(); }; 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -