javascript - Protractor: Return Repeater Count from Prototype -


i have behavior can't understand:

cart.prototype.getcouponscount = function() {      // loop through rows of coupons available in cart     ele.cartcouponslist.count().then(function(count) {          console.log("amount of items in cart:", count);         return count;     }); }; 

when called this:

var cart = require("../../../../lib/cartlib"); var cart = new cart();  expect(cart.getcouponscount()).tobe(2); 

returns undefined, in console can see correct coupon amount being printed. it's not returning count back.

similarly have working gettext() method, therefore why can't understand why count() method behave differently.

working method:

cart.prototype.getevent = function(row) {      var carthistory = new cart();     var parent = carthistory.getcartcoupon(row);      var child = parent.element(by.binding("selection.event.name"))         .gettext().then(function(e) {              console.log(e);             return e;         }); }; 

anyone can point me in right direction?

there no return function, add it:

cart.prototype.getcouponscount = function() {      // here      return ele.cartcouponslist.count().then(function(count) {          console.log("amount of items in cart:", count);         return count;     }); }; 

Comments

Popular posts from this blog

javascript - Complete OpenIDConnect auth when requesting via Ajax -

apache - PHP Soap issue while content length is larger -

c# - Replace text in MailItem Body -