Protractor - compare numbers

孤街醉人 提交于 2019-12-05 09:51:24

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's possible to resolve only the first promise. Protractor adapts expect to "understand" promises. Refer https://github.com/angular/protractor/blob/master/docs/control-flow.md#protractor-adaptations and https://github.com/angular/protractor/issues/128.

element.all(by.repeater('app in userApps')).count().then(function (first) {
    // Do any changes here...
    var second = element.all(by.repeater('app in userApps')).count();
    // Here expect() resolves 'second'
    expect(second).toEqual(first + 1);
})

});

You are doing absolutely right. But Before comparison, Check whether your result value is number type or not.

Example-

expect(sub).toEqual(jasmine.any(Number));

Then perform an operation for expected conditions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!