@Test public void shouldNotMatchConditionWhenAttributeDoesNotMatchRegex() { when(mockElement.getAttribute("clas")).thenReturn("myclass modifier3 modifier4"); AttributeMatchesCondition condition = new AttributeMatchesCondition("class", "(.*)modifier1(.*)"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Override public boolean apply(final WebElement element) { try { String attributeValue = element.getAttribute(attribute); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(attributeValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } }
AttributeMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String attributeValue = element.getAttribute(attribute); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(attributeValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } }
AttributeMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String attributeValue = element.getAttribute(attribute); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(attributeValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } AttributeMatchesCondition(final String attribute, final String regex);  AttributeMatchesCondition(final String attribute, final String regex, final int flags); }
AttributeMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String attributeValue = element.getAttribute(attribute); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(attributeValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } AttributeMatchesCondition(final String attribute, final String regex);  AttributeMatchesCondition(final String attribute, final String regex, final int flags); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
AttributeMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String attributeValue = element.getAttribute(attribute); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(attributeValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } AttributeMatchesCondition(final String attribute, final String regex);  AttributeMatchesCondition(final String attribute, final String regex, final int flags); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }