Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor - compare numbers

In my program I'm calculating two numbers, and I want to make sure that subtraction of them equals 1.

this is the code:

var firstCount=element.all(by.repeater('app in userApps')).count();
var secondCount=element.all(by.repeater('app in userApps')).count();

so far it's good- I'm getting the numbers. the problem comes next:

var sub=secondCount-firstCount;
expect(sub).toEqual(1);

I'm getting this error:

Expected NaN to equal 1.

any idea?

like image 364
user2880391 Avatar asked Sep 28 '22 22:09

user2880391


1 Answers

Both firstCount and secondCount are promises that are needed to be resolved:

element.all(by.repeater('app in userApps')).count().then(function (first) {
    element.all(by.repeater('app in userApps')).count().then(function(second) {
        expect(first - second).toEqual(1);
    })
});
like image 112
alecxe Avatar answered Oct 03 '22 03:10

alecxe