Counter of elements inside ng-repeat with protractor

I want to check that mine ng-repeatgenerates more than 1 element.

<div ng-repeat="topic in topics">
  <div class="topic-name">{{topic.name}}</div>
</div>

How can i do this? I can not find in the docs ...
Is there something like this?

expect(element.all(by.repeater('topic in topics')).count()).toBeMoreThan(1);
+4
source share
2 answers

It is in the Jasmine 2.0 docs here . Try the following code:

var count = element.all(by.repeater('topic in topics'));
count.then(function(result){
    expect(result.length).toBeGreaterThan(1);
});
+5
source

As long as the accepted answer works, it can now be made much simpler. You can simply:

expect(element.all(by.repeater('topic in topics')).count()).toBeGreaterThan(1);
+4
source

Source: https://habr.com/ru/post/1584441/


All Articles