Skip to content

Instantly share code, notes, and snippets.

@mspiegel
Created October 6, 2014 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mspiegel/58125c8e56e4ba68a769 to your computer and use it in GitHub Desktop.
Save mspiegel/58125c8e56e4ba68a769 to your computer and use it in GitHub Desktop.
public void clickWhenVisible(By locator) {
int counter = 0;
boolean retry;
do {
try {
retry = false;
wait.until(ExpectedConditions.elementToBeClickable(locator));
driver.findElement(locator).click();
} catch (WebDriverException ex) {
if (counter < TestManagerConfiguration.DEFAULT_RETRY) {
counter++;
log.warn(ex.toString());
log.warn("Retry number " + counter);
retry = true;
} else {
throw ex;
}
}
} while (retry);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment