@Test public void conditionsOfAllElementsLocatedReturnsWebElements() { List<WebElement> webElements = Lists.newArrayList(mockElement); when(mockDriver.findElements(By.id("someid"))).thenReturn(webElements); when(mockCondition.apply(mockElement)).thenReturn(true); List<WebElement> allElementsLocated = wait.until(CinnamonExpectedConditions.conditionOfAllElementsLocated(By.id("someid"), mockCondition)); assertEquals(webElements, allElementsLocated); }
public static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition) { return context -> { try { final List<WebElement> elements = Lists.newArrayList(Iterables.filter(context.findElements(by), condition)); return elements.isEmpty() ? null : elements; } catch (final WebDriverException e) { return null; } }; }
CinnamonExpectedConditions { public static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition) { return context -> { try { final List<WebElement> elements = Lists.newArrayList(Iterables.filter(context.findElements(by), condition)); return elements.isEmpty() ? null : elements; } catch (final WebDriverException e) { return null; } }; } }
CinnamonExpectedConditions { public static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition) { return context -> { try { final List<WebElement> elements = Lists.newArrayList(Iterables.filter(context.findElements(by), condition)); return elements.isEmpty() ? null : elements; } catch (final WebDriverException e) { return null; } }; }  }
CinnamonExpectedConditions { public static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition) { return context -> { try { final List<WebElement> elements = Lists.newArrayList(Iterables.filter(context.findElements(by), condition)); return elements.isEmpty() ? null : elements; } catch (final WebDriverException e) { return null; } }; }  static ExpectedCondition<Boolean> conditionToBe(final Condition<WebDriver> condition); static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition); static Function<SearchContext, WebElement> conditionOfElementLocated(final By by, final Condition<WebElement> condition); static Function<SearchContext, Boolean> elementCountToBe(final By by, final Condition<WebElement> condition, final int count); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final int zeroBasedIndex); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final String title); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final String title, final boolean partial); }
CinnamonExpectedConditions { public static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition) { return context -> { try { final List<WebElement> elements = Lists.newArrayList(Iterables.filter(context.findElements(by), condition)); return elements.isEmpty() ? null : elements; } catch (final WebDriverException e) { return null; } }; }  static ExpectedCondition<Boolean> conditionToBe(final Condition<WebDriver> condition); static Function<SearchContext, List<WebElement>> conditionOfAllElementsLocated(final By by, final Condition<WebElement> condition); static Function<SearchContext, WebElement> conditionOfElementLocated(final By by, final Condition<WebElement> condition); static Function<SearchContext, Boolean> elementCountToBe(final By by, final Condition<WebElement> condition, final int count); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final int zeroBasedIndex); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final String title); static ExpectedCondition<WebDriver> windowToBeAvailableAndSwitchToIt(final String title, final boolean partial);  }