量角器:等待方法不起作用

Лил*_*ина 3 asynchronous timeout jasmine angularjs protractor

我尝试使用wait()方法而不是sleep(),但它不起作用.我有代码:

 browser.actions().click(filter_field).perform();
 browser.sleep(3000);
 if (baloon_info.isPresent()) { //some expections }
 else { expect(true).toBe(false); }
Run Code Online (Sandbox Code Playgroud)

现在我想做点什么:

 var present_pri = browser.wait(function () {
   return balloon_info.isPresent();
 }, 3000);
 if (present_pri) { //some expections }
 else { expect(true).toBe(false); }
Run Code Online (Sandbox Code Playgroud)

但如果气球不存在,我有错误信息:Wait timed out after 3117ms而不是expected true to be false(present_pri == false)

我试着写:

var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(balloon_warning), 3000);
expect(balloon_warning.isPresent()).toBeTruthy();
Run Code Online (Sandbox Code Playgroud)

但我总是有同样的错误.我做错了什么?

ale*_*cxe 5

您需要处理等待超时错误:

browser.wait(EC.presenceOf(balloon_warning), 3000).then(function () {
    // success handler
}, function (error) {
    expect(true).toBe(false);
});
Run Code Online (Sandbox Code Playgroud)