量角器 - 比较数字

use*_*391 5 javascript subtraction end-to-end angularjs protractor

在我的程序中,我正在计算两个数字,我想确保它们的减法等于1.

这是代码:

var firstCount=element.all(by.repeater('app in userApps')).count();
var secondCount=element.all(by.repeater('app in userApps')).count();
Run Code Online (Sandbox Code Playgroud)

到目前为止它很好 - 我得到的数字.接下来的问题是:

var sub=secondCount-firstCount;
expect(sub).toEqual(1);
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

Expected NaN to equal 1.
Run Code Online (Sandbox Code Playgroud)

任何的想法?

ale*_*cxe 4

和firstCount都是需要解决secondCount的承诺:

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);
    })
});
Run Code Online (Sandbox Code Playgroud)