### Question:
CssPropertyContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); return cssValue != null && cssValue.contains(value); } catch (NullPointerException | WebDriverException e) { return false; } } CssPropertyContainsCondition(final String cssProperty, final String value); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldMatchConditionWhenCssPropertyContainsValue() { when(mockElement.getCssValue("color")).thenReturn("rgba(68, 68, 68, 1)"); CssPropertyContainsCondition condition = new CssPropertyContainsCondition("color", "68"); assertThat(condition.apply(mockElement), equalTo(true)); }
@Test public void shouldNotMatchConditionWhenCssPropertyDoesNotContainValue() { when(mockElement.getCssValue("color")).thenReturn("rgba(68, 68, 68, 1)"); CssPropertyContainsCondition condition = new CssPropertyContainsCondition("color", "69"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleNullReturn() { when(mockElement.getCssValue("color")).thenReturn(null); CssPropertyContainsCondition condition = new CssPropertyContainsCondition("color", "68"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleExceptionWhenElementHasStaleReference() { when(mockElement.getCssValue("color")).thenThrow(new StaleElementReferenceException("stale")); CssPropertyContainsCondition condition = new CssPropertyContainsCondition("color", "68"); assertThat(condition.apply(mockElement), equalTo(false)); }