@Test public void shouldNotMatchConditionWhenTextDoesNotMatchRegex() { when(mockWebElementConverter.getTextFrom(mockElement)).thenReturn("abcdef"); TextMatchesCondition condition = new TextMatchesCondition(mockWebElementConverter, 0x00, "^bcd"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Override public boolean apply(WebElement element) { try { Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(webElementConverter.getTextFrom(element)); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } }
TextMatchesCondition extends Condition<WebElement> { @Override public boolean apply(WebElement element) { try { Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(webElementConverter.getTextFrom(element)); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } }
TextMatchesCondition extends Condition<WebElement> { @Override public boolean apply(WebElement element) { try { Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(webElementConverter.getTextFrom(element)); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } TextMatchesCondition(final String regex);  TextMatchesCondition(final int flags, final String regex);   TextMatchesCondition(final WebElementConverter webElementConverter, final int flags, final String regex); }
TextMatchesCondition extends Condition<WebElement> { @Override public boolean apply(WebElement element) { try { Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(webElementConverter.getTextFrom(element)); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } TextMatchesCondition(final String regex);  TextMatchesCondition(final int flags, final String regex);   TextMatchesCondition(final WebElementConverter webElementConverter, final int flags, final String regex); @Override boolean apply(WebElement element); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
TextMatchesCondition extends Condition<WebElement> { @Override public boolean apply(WebElement element) { try { Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(webElementConverter.getTextFrom(element)); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } TextMatchesCondition(final String regex);  TextMatchesCondition(final int flags, final String regex);   TextMatchesCondition(final WebElementConverter webElementConverter, final int flags, final String regex); @Override boolean apply(WebElement element); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }