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 (b
As per your question, what i understand is that you are trying to find if an element is present in the DOM (however, it doesn't necessarily mean that it should be displayed). You are getting a wait error because you are waiting for an element that is not present in the DOM. So it throws an error as you have shown above. To resolve it, try to expect the presence of the element without waiting for it. Because by default protractor has a predefined wait time out for checking for the presence of an element in DOM. Here's a small snippet -
it('Check for presence of the element', function(){
expect(balloon_warning.isPresent()).toBe(true);
}, 60000); //extra timeout of 60000 so that async error doesn't show up
Now if you want to use wait at any cost then checkout below example -
it('Check for element with wait time of 3000 ms', function(){
var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(balloon_warning), 3000).then(function(){
expect(balloon_warning.isPresent()).toBeTruthy();
},function(err){
console.log('error');
});
}, 60000);
Here if element is not found then wait function will throw error and gets printed in console. Hope it helps.
You need to handle the wait timeout error:
browser.wait(EC.presenceOf(balloon_warning), 3000).then(function () {
// success handler
}, function (error) {
expect(true).toBe(false);
});
Finally I found one more solution:
browser.wait(function () {
return balloon_info.isPresent();
}, 3000).then(function () {
// success handler
}).thenCatch(function () {
expect(true).toBe(false);
});