@Test public void shouldHandleExceptionWhenElementHasStaleReference() { when(mockElement.getCssValue("color")).thenThrow(new StaleElementReferenceException("stale")); CssPropertyEqualsCondition condition = new CssPropertyEqualsCondition("color", "^rgba\\((.*)\\)$"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(cssValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } }
CssPropertyMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(cssValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } }
CssPropertyMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(cssValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } CssPropertyMatchesCondition(final String cssProperty, final String regex);  CssPropertyMatchesCondition(final String cssProperty, final String regex, final int flags); }
CssPropertyMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(cssValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } CssPropertyMatchesCondition(final String cssProperty, final String regex);  CssPropertyMatchesCondition(final String cssProperty, final String regex, final int flags); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
CssPropertyMatchesCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); Pattern pattern = flags == 0x00 ? Pattern.compile(regex) : Pattern.compile(regex, flags); Matcher matcher = pattern.matcher(cssValue); return matcher.matches(); } catch (NullPointerException | PatternSyntaxException | WebDriverException e) { return false; } } CssPropertyMatchesCondition(final String cssProperty, final String regex);  CssPropertyMatchesCondition(final String cssProperty, final String regex, final int flags); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }