下面的断言代码在CI中不起作用(可能是因为速度慢),但在CI中的本地系统中工作得很好,我根本得不到元素列表,或者它只返回实际元素数组中的一个或两个元素
var expectedFromLevels = ['Level 2', 'Level 3', 'Level 4'];
var expectedToLevels= ['Level 3', 'Level 4','Level 5'];
expect(dashboard.getAllFromLevels()).toEqual(expectedFromLevels)
expect(dashboard.getAllToLevels()).toEqual(expectedToLevels)//this has to be called only after getAllFromLevels is assertion is complete
//definition of getAllFromLevels()
getAllFromLevels : {
value: function () {
return element.all(by.css('#from-levels .nlq-sel--level')).getText();
}
//definition of getAllToLevels()
getAllToLevels : {
value: function() {
return element.all(by.css('#to-levels .nlq-sel--level')).getText();
};
**Results::**
In my local system: passed
**In CI:::**
Expected [ 'Level 2', 'Level 3' ] to equal [ 'Level 2', 'Level 3', 'Level 4' ].
Expected [ 'Level 3', '' ] to equal [ 'Level 3', 'Level 4', 'Level 5' ].发布于 2016-01-28 13:20:12
我在CI中通过添加浏览器等待语句修复了这个问题-我知道这不是理想的方法,但这是暂时有效的解决方法-
getAllLevelsCount : {
value: function (elements, n) {
return function () {
return elements.count(function (count) {
return count >= n;
});
};
}
browser.wait(dashboard.getAllLevelsCount($$("cssid"), 3) , 10000);https://stackoverflow.com/questions/35044053
复制相似问题