加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 量角器:wait方法不起作用

发布时间:2020-12-17 17:04:19 所属栏目:安全 来源:网络整理
导读:我尝试使用wait()方法而不是sleep(),但它不起作用. 我有代码: browser.actions().click(filter_field).perform(); browser.sleep(3000); if (baloon_info.isPresent()) { //some expections } else { expect(true).toBe(false); } 现在我想做点什么: var p
我尝试使用wait()方法而不是sleep(),但它不起作用.
我有代码:

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

现在我想做点什么:

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

但是如果气球不存在,我会收到错误消息:3117ms后等待超时而不是预期true为假(present_pri == false)

我试着写:

var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(balloon_warning),3000);
expect(balloon_warning.isPresent()).toBeTruthy();

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

解决方法

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读