angularjs - Not able to click the Matched Row button in the repeater in protractor Test Case? -


this test code when run test click last row button, not able click matched row button.

it('repeater element check',function(){  browser.get('http://test.worker.mondaz.com/#/company/select');  browser.sleep(1000);  var result = element.all(by.repeater('co in colist'));  result.then(function(arr) {       (var = 0; < arr.length; ++i) {    arr[i].element(by.binding('co.nm')).gettext().then(function(text) {     if(text=="monday ventures private limited") {       console.log(text);      console.log("mathced");      console.log(i);//this giving total row count        element(by.repeater('cocolist').row(i)).element(by.name('customradio')).click();     }     });     }   });    } 

i beginner angular protractor test case.

instead of using for-loop on array of promises returned element.all, should use element.all(locator).filter(filterfn) filter out "monday" element.

if understand present code correctly, first loop through array of promises without waiting completion. because of i equal total number of rows. matched row's function (text) { ... } executed, value of i did not expect.

edit: including working code based on answer, taken @chandru-yadhav's comment:

var items = element.all(by.repeater('co in colist')).filter(function(item) {    return item.element(by.binding('co.nm')).gettext().then(function(label) {      return label === 'monday ventures private limited';    });  });  items.get(0).element(by.name('customradio')).click();  

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -