@Override
  public <T> T until(Function<Void, T> isTrue) {
    long end = clock.laterBy(timeoutInMillis);
    NotFoundException lastException = null;

    do {
      try {
        T value = isTrue.apply(null);

        if (value != null && !Boolean.FALSE.equals(value)) {
          return value;
        }
      } catch (NotFoundException exception) {
        // Common case in many conditions, so swallow here, but be ready to
        // rethrow if it the element never appears.
        lastException = exception;
      }
      sleep();
    } while (clock.isNowBefore(end));

    throw new TimeoutException(String.format("Timed out after %d seconds",
        SECONDS.convert(timeoutInMillis, MILLISECONDS)), lastException);
  }
@param clock clock to use when measuring the timeout
@param sleepIntervalInMillis amount of time to sleep between attempts in milliseconds
@param timeoutInMillis timeout in milliseconds
selendroid-server/src/main/java/io/selendroid/server/android/AndroidWait.java