量角器-比较数字 [英] Protractor - compare numbers
本文介绍了量角器-比较数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的程序中,我正在计算两个数字,我想确保将它们相减等于1.
In my program I'm calculating two numbers, and I want to make sure that subtraction of them equals 1.
这是代码:
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);
我收到此错误:
Expected NaN to equal 1.
有什么主意吗?
推荐答案
firstCount
和secondCount
都是承诺,需要解决:>
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);
})
});
这篇关于量角器-比较数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文