Example usage for org.openqa.selenium.support.ui Wait until

List of usage examples for org.openqa.selenium.support.ui Wait until

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui Wait until.

Prototype

<T> T until(Function<? super F, T> isTrue);

Source Link

Document

Implementations should wait until the condition evaluates to a value that is neither null nor false.

Usage

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public WebElement waitForElementToBeClickable(final WebElement element, int timeout) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeout, 100);
    wait.until(ExpectedConditions.elementToBeSelected(element));
    return element;
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public void waitForElementToBeClickable(final By by) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME, 100);
    wait.until(ExpectedConditions.elementToBeClickable(waitAndFindElement(by)));
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public void waitForElementToDissappear(final By byLocator) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME, 100);
    wait.until(ExpectedConditions.invisibilityOfElementLocated(byLocator));
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public void pageTitleWait(String title, int timeOut) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeOut);
    wait.until(ExpectedConditions.titleIs(title));
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public List<WebElement> waitAndFindElements(By by) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME);
    wait.until(ExpectedConditions.visibilityOf(getDriver().findElement(by)));
    return getDriver().findElements(by);
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public WebElement waitFluentForElement(final By by) {
    WebElement element = null;// w w w.  j a  va2s .c o  m
    Wait<WebDriver> wait = new FluentWait<WebDriver>(getDriver()).withTimeout(30, TimeUnit.SECONDS)
            .pollingEvery(2, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);

    element = wait.until(new Function<WebDriver, WebElement>() {
        public WebElement apply(WebDriver driver) {
            return getDriver().findElement(by);
        }
    });
    return element;
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public void waitForPageToLoad() {
    ExpectedCondition<Boolean> expectedCondition = new ExpectedCondition<Boolean>() {
        @Override/*  ww  w  .j  a v a  2 s  .  c  o m*/
        public Boolean apply(WebDriver driver) {
            return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
        }
    };
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME);
    wait.until(expectedCondition);
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

/**
 * For waiting without WebDriver: Wait for function will be true or return some except false.
 *
 * @param condition        Function for waiting {@link Function}
 * @param waitWith         Object who will helping to wait (which will be passed to {@link Function#apply(Object)})
 * @param timeOutInSeconds Time-out in seconds
 * @param <F>              Type of waitWith param
 * @param <T>              Type of object which is waiting
 * @return Object which waiting for or null - is exceptions occured
 *//*from w  ww .  ja v a 2 s.  c  om*/
public static <F, T> T waitFor(Function<F, T> condition, F waitWith, long timeOutInSeconds) {
    Wait<F> wait = new FluentWait<>(waitWith).withTimeout(timeOutInSeconds, TimeUnit.SECONDS).pollingEvery(300,
            TimeUnit.MILLISECONDS);
    try {
        return wait.until(condition);
    } catch (Exception | AssertionError e) {
        LOG.warn("Waiting was not successfull", e);
    }
    return null;
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.ExperimentsTablePage.java

License:Apache License

private void waitForExperimentTableToLoad() {
    Wait<WebDriver> wait = new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS)
            .pollingEvery(1, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);

    wait.until(ExpectedConditions.invisibilityOfElementWithText(
            By.xpath("//*[@id=\"experiments-table\"]/tbody/tr/td"), "Loading..."));
}