量角器:wait方法是不行的 [英] Protractor: wait method isn't work
本文介绍了量角器:wait方法是不行的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用wait()方法,而不是睡觉(),但它不工作。
我有code:
I try to use wait() method instead sleep(), but it isn't working. I had code:
browser.actions().click(filter_field).perform();
browser.sleep(3000);
if (baloon_info.isPresent()) { //some expections }
else { expect(true).toBe(false); }
现在我想要做的是这样的:
Now I want to do something like:
var present_pri = browser.wait(function () {
return balloon_info.isPresent();
}, 3000);
if (present_pri) { //some expections }
else { expect(true).toBe(false); }
但是,如果气囊没有present我有错误消息:等待3117ms后超时
而不是预计真为假
(present_pri == FALSE)
But if balloon isn't present I have the error message: Wait timed out after 3117ms
instead expected true to be false
(present_pri == false)
我tryed写的:
I tryed to write:
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(balloon_warning), 3000);
expect(balloon_warning.isPresent()).toBeTruthy();
不过,我总是有相同的错误。我做错了吗?
But I always have the same error. What I doing wrong?
推荐答案
您需要的处理等待超时错误的:
browser.wait(EC.presenceOf(balloon_warning), 3000).then(function () {
// success handler
}, function (error) {
expect(true).toBe(false);
});
这篇关于量角器:wait方法是不行的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文