javascript - Protractor ElementArrayFinder.filter() running only once? -
i having trouble filtering elementarrayfinder of <tr>
elements more once in page object. second filter being called right after first one. in following code, first verifying number in table, , filtering again click on it. reason don't combine these because in functions rely on parameter batchnumber of function, , different.
filter:
function verifybatchinlist(batchnumber){ batch_list_table.filter(function(elem, i){ return elem.element(by.xpath('./td[1]')).gettext().then(function(text){ text = text.trim(); return text === batchnumber; }); }).then(function(results){ if(results.length < 1){ throw new error('could not find batch "'+batchnumber+'" in batch list'); } }); } function editbatch(batchnumber){ selectbatch(batchnumber); edit_button.click(); //this never happens } function selectbatch(batchnumber){ batch_list_table.filter(function(elem, i){ //this function never runs return elem.element(by.xpath('./td[1]')).gettext().then(function(text){ text = text.trim(); return batchnumber === text; }); }).then(function(results){ //this never runs either if(results.length < 1){ throw new error('could not find batch "'+batchnumber+'" in batch list'); } results[0].click(); });
when put breakpoint inside of filter function, gets there first iteration, not second. spec running looks this.
it('can commit batch', function(){ page.addspecimens.getbatchid().then(function(text){ batchids[0] = text.split(' ')[0]; page.addspecimens.commitbatch(); page = new pages.batchlist(); browser.sleep(2000); //for page load, temporary page.verifybatchinlist(batchids[0]); //this works fine }); }); it('can edit batch',function(){ page.editbatch(batchids[0]); //this runs, never filters });
the html table first td being batch number.
Comments
Post a Comment