public static WebElement waitForElement(By by, int timeout, WebDriver driver) {
    WebDriverWait wait = new WebDriverWait(driver, timeout);
    WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(by));

    return element;
  }
Wait for the callable to return either "not null" or "true". Exceptions are caught and only
rethrown if we time out.

@param until Condition that we're waiting for.
@param duration How long to wait.
@param in Unit in which duration is measured.
@return Whatever the condition returns.
selendroid-client/src/main/java/io/selendroid/client/waiter/TestWaiter.java