Search in sources :

Example 1 with FluentWait

use of org.openqa.selenium.support.ui.FluentWait in project java-client by appium.

the class ByChained method findElement.

@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());
    }
}
Also used : FluentWait(org.openqa.selenium.support.ui.FluentWait) By(org.openqa.selenium.By) SearchContext(org.openqa.selenium.SearchContext) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Aggregations

By (org.openqa.selenium.By)1 NoSuchElementException (org.openqa.selenium.NoSuchElementException)1 SearchContext (org.openqa.selenium.SearchContext)1 TimeoutException (org.openqa.selenium.TimeoutException)1 WebElement (org.openqa.selenium.WebElement)1 FluentWait (org.openqa.selenium.support.ui.FluentWait)1