I writing some automation test and i have many problems with exceptions. How do you handle this problem in Your projects? I want to write universal function for veryfing elements, clicking on it and handling occured exceptions. What do You think about function below? Do You have any better solution for this cases?
public void verifyAndClick(WebElement element) {
for (int i = 0; i < 2; i++) {
try {
element.click();
break;
} catch (StaleElementReferenceException e) {
System.out.println("StaleElementReferenceException occured , retrying in 100 ms ");
} catch (NoSuchElementException e) {
System.out.println("NoSuchElementException occured, retrying in 100 ms ");
} catch (ElementClickInterceptedException e) {
System.out.println("ElementClickInterceptedException occured, retrying in 100 ms ");
}
try {
Thread.sleep(150);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Aucun commentaire:
Enregistrer un commentaire