Skip to content Skip to sidebar Skip to footer

How To Get Iterator Index/key Using Protractor + Angular?

Is there a way to access the iterator index/key when looking for elements by repeater? protractor.By.repeater('(id,cat) in pets') In this case I'm looking to get access to 'id' of

Solution 1:

You're looking to evaluate something that's not on the page, so the 'row' and 'column' methods won't work. If you just use the repeater, you will get an array of all of the rows. You can then use the evaluate command to evaluate Angular expressions in the context of that element. For example (using shortened syntax),

element.all(by.repeater('(id, cat) in pets')).then(function(arr) {
  arr[0].evaluate('cat.id'); // This is a promise which resolves to the id.
});

Post a Comment for "How To Get Iterator Index/key Using Protractor + Angular?"