@Override public FluentWait<WebDriver, FLUENT> pollingEvery(long duration, TimeUnit unit) { wait.pollingEvery(duration, unit); return this; }
@Override public FluentWait<WebDriver, FLUENT> pollingEvery(long duration, TimeUnit unit) { wait.pollingEvery(duration, unit); return this; }
public void waitWhile(Predicate<WebDriver> whilePredicate, int timeout) { wait = new WebDriverWait(driver, timeout); wait.pollingEvery(pollingMillis, TimeUnit.MILLISECONDS); wait.until(Predicates.not(whilePredicate)); }
public void startOrder(WebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, 30); //Throttle the polling! wait.pollingEvery(1500, TimeUnit.MILLISECONDS); wait.until(new Predicate<WebDriver>() { public boolean apply(WebDriver input) { boolean successfulClick = false; //FIXME: Need to check for something that should occur after the click happens successfully By lookupAfterClick = By.cssSelector(""); WebElement nextElement = ExpectedConditions.visibilityOfElementLocated(lookupAfterClick).apply(input); if (nextElement == null) { System.out.println("Not there yet, Keep trying!"); By startOrderLookup = By.cssSelector("form[action='/menu/startyourorder']"); WebElement startOrder =ExpectedConditions.visibilityOfElementLocated(startOrderLookup).apply(input); if (startOrder != null) { System.out.println("Clicking Start Order!"); startOrder.click(); } else { System.out.println("Start Order isn't visible!"); } } else { System.out.println("Hey, That worked!"); successfulClick = true; } return successfulClick; } }); }
public boolean waitWhile(final ExpectedCondition<Boolean> whileExpectedCondition, int timeout) { wait = new WebDriverWait(driver, timeout); wait.pollingEvery(pollingMillis, TimeUnit.MILLISECONDS); Boolean result = wait.until(new ExpectedCondition<Boolean>() { public Boolean apply( WebDriver input) { return !whileExpectedCondition.apply(input); } }); return !result; }
/** * Repeatedly invoking {@link ExpectedCondition#apply(Object)} on * this page's WebDriver until one of the following * occurs: * <ol> * <li>the function returns neither null nor false</li> * <li>the timeout expires</li> * <li>the current thread is interrupted</li> * </ol> * * @param untilExpectedCondition * The condition to apply * @param timeout * timeout in seconds * @param <T> * The ExpectedCondition's return type. * @return The value returned by the {@link ExpectedCondition}. */ public <T> T waitUntil(ExpectedCondition<T> untilExpectedCondition, int timeout) { wait = new WebDriverWait(driver, timeout); wait.pollingEvery(pollingMillis, TimeUnit.MILLISECONDS); T result = wait.until(untilExpectedCondition); return result; }
/** * Repeatedly applies the given predicate on this page's driver until the * timeout expires or the predicate evaluates to true. * * @param untilPredicate * The predicate to wait on. * @param timeout * timeout in seconds */ public void waitUntil(Predicate<WebDriver> untilPredicate, int timeout) { wait = new WebDriverWait(driver, getAjaxTimeout()); wait.pollingEvery(pollingMillis, TimeUnit.MILLISECONDS); wait.until(untilPredicate); }
wait.pollingEvery(500, TimeUnit.MILLISECONDS); wait.until(navTestCondition);
wait.pollingEvery(500, TimeUnit.MILLISECONDS); // Setting too low can cause StaleElementException inside the
/** * Asserts that all {@link ElementMustExist}s fields are visible in this * page object. */ @Override protected void assertInModule() { driver.manage().timeouts().implicitlyWait(pollingMillis, TimeUnit.MILLISECONDS); for (final Field currField: this.getClass().getDeclaredFields()) { currField.setAccessible(true); if (currField.isAnnotationPresent(ElementMustExist.class)) { By by = new Annotations(currField).buildBy(); report.report("Waiting for Element (@ElementMustExist): " + by); final WebDriverWait wait = new WebDriverWait(driver, getAjaxTimeout()); wait.ignoring(WebDriverException.class); wait.pollingEvery(100, TimeUnit.MILLISECONDS); wait.until(ExpectedConditions.visibilityOfElementLocated(by)); } } }
noThreadSleep.pollingEvery(250, TimeUnit.MILLISECONDS);
try { return new WebDriverWait(driver, timeOutInSeconds) .pollingEvery(500, TimeUnit.MILLISECONDS).until( expectedCondition); } catch (TimeoutException e) {