private void checkPresenceOfWebElement() { try { if (!driverIsDisabled()) { waitForCondition().until(elementIsDisplayed()); } } catch (Throwable error) { if (webElement != null) { throwShouldBeVisibleErrorWithCauseIfPresent(error, error.getMessage()); } else { throwNoSuchElementExceptionWithCauseIfPresent(error, error.getMessage()); } } }
@Override public WebElementFacade waitUntilVisible() { try { if (!driverIsDisabled()) { waitForCondition().until(elementIsDisplayed()); } } catch (Throwable error) { if (webElement != null) { throwShouldBeVisibleErrorWithCauseIfPresent(error, error.getMessage()); } else { throwNoSuchElementExceptionWithCauseIfPresent(error, error.getMessage()); } } return this; }
private void throwShouldBePresentErrorWithCauseIfPresent( final Throwable timeout, final String defaultMessage) { String timeoutMessage = (timeout.getCause() != null) ? timeout.getCause().getMessage() : timeout.getMessage(); String finalMessage = (StringUtils.isNotEmpty(timeoutMessage)) ? timeoutMessage : defaultMessage; throw new ElementShouldBePresentException(finalMessage, timeout); }