/** Wait until the "until" condition returns true or time runs out. * * @param message the failure message * @param timeoutInMilliseconds the amount of time to wait before giving up * @throws WaitTimedOutException if "until" doesn't return true until the timeout * @see #until() */ public void wait(String message) { wait(message, DEFAULT_TIMEOUT, DEFAULT_INTERVAL); }
public boolean waitForTextPresent(final String text, long timeout) { Wait wait = new Wait() { @Override public boolean until() { try { return CustomSelenium.this.isTextPresent(text); } catch (SeleniumException e) { return false; } } }; try { wait.wait("Error: text " + text + " not present in the page", timeout, 50); } catch (NumberFormatException e) { log.error(e.getMessage(), e); throw e; } catch (WaitTimedOutException e) { log.warn(e.getMessage(), e); return false; } return true; }
/** Wait until the "until" condition returns true or time runs out. * * @param message the failure message * @param timeoutInMilliseconds the amount of time to wait before giving up * @param intervalInMilliseconds the interval to pause between checking "until" * @throws WaitTimedOutException if "until" doesn't return true until the timeout * @see #until() */ public void wait(String message, long timeoutInMilliseconds, long intervalInMilliseconds) { long start = System.currentTimeMillis(); long end = start + timeoutInMilliseconds; while (System.currentTimeMillis() < end) { if (until()) return; try { Thread.sleep(intervalInMilliseconds); } catch (InterruptedException e) { throw new RuntimeException(e); } } throw new WaitTimedOutException(message); }
/** Wait until the "until" condition returns true or time runs out. * * @param message the failure message * @param timeoutInMilliseconds the amount of time to wait before giving up * @throws WaitTimedOutException if "until" doesn't return true until the timeout * @see #until() */ public void wait(String message, long timeoutInMilliseconds) { wait(message, timeoutInMilliseconds, DEFAULT_INTERVAL); }
public Wait(String messageToShowIfTimeout) { wait(messageToShowIfTimeout, DEFAULT_TIMEOUT, DEFAULT_INTERVAL); }