### Question:
CssPropertyEqualsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { String cssValue = element.getCssValue(cssProperty); return cssValue != null && cssValue.equals(value); } catch (NullPointerException | WebDriverException e) { return false; } } CssPropertyEqualsCondition(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 shouldMatchConditionWhenCssPropertyEqualsValue() { when(mockElement.getCssValue("font-weight")).thenReturn("700"); CssPropertyEqualsCondition condition = new CssPropertyEqualsCondition("font-weight", "700"); assertThat(condition.apply(mockElement), equalTo(true)); }
@Test public void shouldNotMatchConditionWhenCssPropertyDoesNotEqualValue() { when(mockElement.getCssValue("font-weight")).thenReturn("700"); CssPropertyEqualsCondition condition = new CssPropertyEqualsCondition("font-weight", "70"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleNullReturn() { when(mockElement.getCssValue("font-weight")).thenReturn(null); CssPropertyEqualsCondition condition = new CssPropertyEqualsCondition("font-weight", "700"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleExceptionWhenElementHasStaleReference() { when(mockElement.getCssValue("font-weight")).thenThrow(new StaleElementReferenceException("stale")); CssPropertyEqualsCondition condition = new CssPropertyEqualsCondition("font-weight", "700"); assertThat(condition.apply(mockElement), equalTo(false)); }