Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor - count elements in repeater and print it

Tags:

I'm trying to count the elements in repeater and to print it to console.

This is the markup:

<div class="col-md-3 ng-scope" ng-repeat="app in userApps" >...< /div> 

currently I'm counting and comparing:

expect(element.all(by.repeater('app in userApps')).count()).toEqual(4);

it works, but I want to be able to print it also.

I've tried this:

var rows = element.all(by.repeater("app in userApps"));
var sum = rows.count(); 
console.log(sum.getText());

but I'm getting:

TypeError: Object [object Object] has no method 'getText'

there are two question actually- 1. am I doing it the correct way? 2. how do I print it to console?

like image 873
user2880391 Avatar asked Jan 21 '15 14:01

user2880391


1 Answers

If I understand your problem correctly, you actually want to print the count and not the entire content, right?

element.all(by.repeater('app in userApps')).count().then(function(count) {
  console.log(count);
});
like image 78
hankduan Avatar answered Oct 20 '22 00:10

hankduan