Reputation: 307
Are any way to filter the result of by.repeater? I need that because I have one ngRepeat inside another ngRepeat and I want to see if the elements are in the correct group. For example:
<div ng-repeat="group in itemsGrouped">
<div ng-repeat="item in group.values">
</div>
</div>
We need Something like this:
describe('group1', function(){
group = ptor.findElements(protractor.By.repeater('group in itemsGrouped').filter('group.name == "group1"'));
it('should have one item', function(){
expect(group.count()).toBe(1);
});
});
// or
describe('group1', function(){
groupCount = ptor.findElements(protractor.By.repeater('group in itemsGrouped')).count();
it('should have one item', function(){
groupCount.then(function(count){
for(var i = 0;i < count; i++) {
ptor.findElements(protractor.By.repeater('item in group.values').filter('group.name == "group1"'));
...
}
});
});
});
Upvotes: 2
Views: 902
Reputation: 4351
there is a built in filter
element.all(by.css('.items li')).filter(function(elem, index) {
return elem.getText().then(function(text) {
return text === 'Third';
});
}).then(function(filteredElements) {
filteredElements[0].click();
});
if you not already know it, take a look at lodash.js
edit: the above example was copied from the docs
Upvotes: 2