Reputation: 11
I want to complete loop ignoring the exception.please suggest?
try {
do{
driver.navigate().refresh();
}while(!driver.findElement(By.partialLinkText("Completed")).isDisplayed());
} catch (Exception e) {
// TODO Auto-generated catch block
}
}
Upvotes: 1
Views: 584
Reputation: 393771
Put the try-catch inside the loop and use a variable to hold the result of the evaluation that you do in the condition :
boolean cont = false;
do {
try {
driver.navigate().refresh();
cont = !driver.findElement(By.partialLinkText("Completed")).isDisplayed();
} catch (Exception e) {
cont = true; // if you want the loop to continue after an exception
// or false if you want to terminate the loop in this case
}
} while (cont);
Upvotes: 4