我有一个测试用例,我通过REST API创建了某些对象。该对象的创建大约需要4-5分钟。我希望测试等到创建完成并验证对象是否已创建。有没有办法用量角器实现这漫长的等待? (我尝试了很多东西,但似乎没有什么能让我更接近我想要实现的目标)
我需要验证的原因(除了确保它有效)之后,我需要测试删除该对象,并且没有办法让测试等到创建完成。
测试代码
it('should create object', function (done) {
//create objects (click on submit buttons basically this part works fine)
var addButton = homePage.addButton;
for (var i = 0; i < 2 ; i++){
addButton.get(i).click();
}
// in my page after I click creation it shows a loader for each item and
// till it completes. When it completes it shows the item itself without
// the progress bar
var pendingObject = element.all(by.id('.throbber-loader')).then(function (items) {
return items;
});
while (pendingObject) {
pendingObject = element.all(by.id('.throbber-loader')).then(function (items) {
return items;
});
browser.wait(constants.SLEEP.MS2K);
}
// the pending objects are completed so I should be getting 0 of them
// and 2 created
expect(pendingObject.count()).toEqual(0);
var finishedObj = homePage.getItems;
finishedObj.then(function(items){
expect(pendingObject.count()).toEqual(2);
})
done();
});
欣赏任何指示。