@Test public void shouldMatchConditionWhenTextContainsValues() { when(mockWebElementConverter.getTextFrom(mockElement)).thenReturn("Some text 1"); TextContainsCondition condition = new TextContainsCondition(mockWebElementConverter, false, "text", "Some"); assertThat(condition.apply(mockElement), equalTo(true)); }
@Override public boolean apply(final WebElement element) { try { final String elementText = StringNormaliser.normalise(webElementConverter.getTextFrom(element)); for (String text : texts) { if (ignoreCase ? !StringUtils.containsIgnoreCase(elementText, text) : !elementText.contains(text)) return false; } return true; } catch (NullPointerException | WebDriverException e) { return false; } }
TextContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { final String elementText = StringNormaliser.normalise(webElementConverter.getTextFrom(element)); for (String text : texts) { if (ignoreCase ? !StringUtils.containsIgnoreCase(elementText, text) : !elementText.contains(text)) return false; } return true; } catch (NullPointerException | WebDriverException e) { return false; } } }
TextContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { final String elementText = StringNormaliser.normalise(webElementConverter.getTextFrom(element)); for (String text : texts) { if (ignoreCase ? !StringUtils.containsIgnoreCase(elementText, text) : !elementText.contains(text)) return false; } return true; } catch (NullPointerException | WebDriverException e) { return false; } } TextContainsCondition(final String... texts);  TextContainsCondition(final boolean ignoreCase, final String... texts);   TextContainsCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); }
TextContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { final String elementText = StringNormaliser.normalise(webElementConverter.getTextFrom(element)); for (String text : texts) { if (ignoreCase ? !StringUtils.containsIgnoreCase(elementText, text) : !elementText.contains(text)) return false; } return true; } catch (NullPointerException | WebDriverException e) { return false; } } TextContainsCondition(final String... texts);  TextContainsCondition(final boolean ignoreCase, final String... texts);   TextContainsCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
TextContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { final String elementText = StringNormaliser.normalise(webElementConverter.getTextFrom(element)); for (String text : texts) { if (ignoreCase ? !StringUtils.containsIgnoreCase(elementText, text) : !elementText.contains(text)) return false; } return true; } catch (NullPointerException | WebDriverException e) { return false; } } TextContainsCondition(final String... texts);  TextContainsCondition(final boolean ignoreCase, final String... texts);   TextContainsCondition(final WebElementConverter webElementConverter, final boolean ignoreCase, final String... texts); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }