I want to use the browser.wait function to repeatedly check if a button element is present for a certain amount of time then use the relevant callback. Below I have the code that doesn't use the wait.
detailsButton.isPresent()
.then(function(present){
if(!present) {
callback();
} else {
callback(new Error('The details button was not present.'));
}
});
I would like some help fixing this code, as I am not sure how the wait function deals with a falure/timeout. Essentially I am asking what should be in the '.then' part of the below code that is less clunky that what I have currently.
browser.driver.wait(function(){
return pgTransactionHistory.transactionHistoryDetails.isPresent();
}, 60000).then(function(){
pgTransactionHistory.transactionHistoryDetails.isPresent()
.then(function(present){
if(!present) {
callback();
} else {
callback(new Error('The details button was not present.'));
}
});
});
Thank you!
There are two ways to do this: First you can use the third argument of browser.wait to a string that will be sent as an error message. Like so:
Or secondly using a second argument to the .then like this: