javascript - protractor js, repeater not iterating through the 'result' -


in protractor.test.js

it('should make sure there listings on page', function() {     var count = element.all(by.repeater('res in result'));     count.then(function(result){     expect(result.length).tobegreaterthan(0);     }, 5000);  }) 

and in index.html

  <div class="item item-text-wrap" ng-click="post($event,res)"  ng-repeat="res in result"  ng-controller="recommendedjobsctrl" ui-sref="menu.jobdetails" > 

the issue says expected 0 greater 0. when change res in tests or other word still gives me same answer. don't think it's reading result

i agree part of igniteram's answer should use count(), cannot use expected conditions on elementarrayfinder (which element.all returns).

instead, try using helper function, taken alecxe's answer on question.

// in helper file util.js  // wait x number of elements util.prototype.presenceofall = function (elem, num) {     console.log('waiting elements ' + elem.locator() + ' have count of ' + num);     return browser.wait(function () {         return elem.count().then(function (count) {             return count >= num;         });     }, 5000, 'failed waiting ' + elem.locator() + ' have ' + num + ' total items'); }; 

usage:

var usernav = element.all(by.css('li.navbar-item')); // wait usernav have 4 elements/buttons util.presenceofall(usernav, 4).then(function () {     // code }); 

also note protractor patches expect implicitly handle promises, don't need use .then() after .count() unless doing else. applying code, modify way:

it('should make sure there listings on page', function() {     var count = element.all(by.repeater('res in result'));     util.presenceofall(count, 5); // change 5 whatever number should there     expect(count.count()).toequal(5);      // have been written since presenceofall returns promise     util.presenceofall(count, 5).then(function() {           expect(count.count()).toequal(5);     }); }); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -