/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * the function returns neither null nor false, * the function throws an unignored exception, * the timeout expires * * Useful in situations where FluentAdapter#await is too specific * (for example to check against page source) * * @param wait generic {@code FluentWait<WebDriver>} instance * @param f function to execute */ public <T>T waitUntil(FluentWait<WebDriver> wait, Function<WebDriver, T> f) { return wait.until(f); }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * the function returns neither null nor false, * the function throws an unignored exception, * the timeout expires * * Useful in situations where FluentAdapter#await is too specific * (for example to check against page source) * * @param <T> the return type * @param wait generic {@code FluentWait<WebDriver>} instance * @param f function to execute * @return the return value */ public <T>T waitUntil(FluentWait<WebDriver> wait, Function<WebDriver, T> f) { return wait.until(f); }
/** * Repeatedly applies this instance's input value to the given function until one of the following occurs: * the function returns neither null nor false, * the function throws an unignored exception, * the timeout expires * * Useful in situations where FluentAdapter#await is too specific * (for example to check against page source) * * @param <T> the return type * @param wait generic {@code FluentWait<WebDriver>} instance * @param f function to execute * @return the return value */ public <T>T waitUntil(FluentWait<WebDriver> wait, Function<WebDriver, T> f) { return wait.until(f); }
private <T> T waitFor(Supplier<T> supplier) { WaitingFunction<T> function = new WaitingFunction<>(); try { FluentWait<Supplier<T>> wait = new FluentWait<>(supplier) .ignoring(NoSuchElementException.class); wait.withTimeout(duration); return wait.until(function); } catch (TimeoutException e) { if (function.foundStaleElementReferenceException != null) { throw StaleElementReferenceException .class.cast(function.foundStaleElementReferenceException); } throw e; } }
@Override public WebElement findElement(SearchContext context) { AppiumFunction<SearchContext, WebElement> searchingFunction = null; for (By by: bys) { searchingFunction = Optional.ofNullable(searchingFunction != null ? searchingFunction.andThen(getSearchingFunction(by)) : null).orElse(getSearchingFunction(by)); } FluentWait<SearchContext> waiting = new FluentWait<>(context); try { checkNotNull(searchingFunction); return waiting.until(searchingFunction); } catch (TimeoutException e) { throw new NoSuchElementException("Cannot locate an element using " + toString()); } } }
@Override public WaitingAction waitPageLoadComplete() { try { driverWait.until( driver -> ((JavascriptExecutor) driver).executeScript("return document.readyState") .toString() .equals("complete")); } catch (Throwable error) { log.error("Page Wait Exception", error); } return this; }
@Override public void until(final Predicate<JavascriptExecutor> isTrue) { try { super.until(isTrue); } catch (final TimeoutException e) { logger.debug(e.getMessage()); } }
private WebElement find(By elementLocation) { this.elementLocation = elementLocation; driverWrapper.driverFluentWait().until(ExpectedConditions.presenceOfElementLocated(elementLocation)); element = driver.findElement(elementLocation); return element; }
/** * NB: might not work as expected: the predicate passed to until seems to be called once, and only once. */ protected void waitUntilDomReady() throws Exception { driverFluentWait(45).until((org.openqa.selenium.WebDriver webDriver) -> { JavascriptExecutor js = (JavascriptExecutor) webDriver; String result = (String) js.executeScript("return document.readyState"); return "complete".equalsIgnoreCase(result); }); }
/** * NB: might not work as expected: the predicate passed to until seems to be called once, and only once. */ protected void waitUntilDomReady() throws Exception { driverFluentWait(45).until((org.openqa.selenium.WebDriver webDriver) -> { JavascriptExecutor js = (JavascriptExecutor) webDriver; String result = (String) js.executeScript("return document.readyState"); return "complete".equalsIgnoreCase(result); }); }
private boolean waitUntilLoginPage() { try { selenium.getDriverWait().withTimeout(Duration.ofSeconds(3)).until(ExpectedConditions.titleContains("Login")); return true; } catch (Exception ex) { return false; } }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.className("nav-pf-vertical"))); } }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(60)).until(ExpectedConditions.presenceOfElementLocated(By.className("navbar-pf-vertical"))); } }
public void accept(WebDriver driver, String originalUrl, Integer pollingTimeout, Integer pollingInterval) { new FluentWait<>(driver) .withTimeout(pollingTimeout, TimeUnit.SECONDS) .pollingEvery(pollingInterval, TimeUnit.SECONDS) .until((WebDriver driver1) -> !driver1.getCurrentUrl().equals(originalUrl)); } }
@Override public void checkReachableWebPage() { selenium.getDriverWait().withTimeout(Duration.ofSeconds(30)).until(ExpectedConditions.presenceOfElementLocated(By.id("inputPassword"))); selenium.getAngularDriver().waitForAngularRequestsToFinish(); selenium.takeScreenShot(); } }
private void waitUntilServiceIsReady() throws Exception { getProvisionedServiceItem().expandServiceItem(); log.info("Waiting until provisioned service will be completed"); selenium.takeScreenShot(); selenium.getDriverWait().withTimeout(Duration.ofMinutes(5)).until(ExpectedConditions.numberOfElementsToBe(By.className("alert-info"), 0)); selenium.takeScreenShot(); }
public Post waitForPostToAppearWithOpenGraph(final String url) { new FluentWait<>(driver).withTimeout(DiscussionsConstants.TIMEOUT, TimeUnit.SECONDS) .until((Function<WikiaWebDriver, Boolean>) input -> wait.forElementVisible(postOpenGraph) .getAttribute("href") .contains(url)); return this; }
public Replies waitForReplyToAppearWithText(final String text) { new FluentWait<>(driver).withTimeout(DiscussionsConstants.TIMEOUT, TimeUnit.SECONDS) .until((Function<WikiaWebDriver, Boolean>) input -> wait.forElementVisible(replyContent) .getText() .contains(text)); return this; }
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer pollingIntervalInSeconds) { new FluentWait<>(driver) .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS) .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS) .until((WebDriver driver1) -> !(new IsAlertPresent().test(driver1))); } }
public void accept(final WebDriver driver, final Integer pollingTimeoutInSeconds, final Integer pollingIntervalInSeconds) { new FluentWait<>(driver) .withTimeout(pollingTimeoutInSeconds, TimeUnit.SECONDS) .pollingEvery(pollingIntervalInSeconds, TimeUnit.SECONDS) .until((WebDriver driver1) -> { return new IsJQueryComplete().test(driver1); }); } }