### Question:
InnerHtmlContainsCondition extends Condition<WebElement> { @Override public boolean apply(final WebElement element) { try { return ignoreCase ? StringUtils.containsIgnoreCase(element.getAttribute("innerHTML"), text) : element.getAttribute("innerHTML").contains(text); } catch (NullPointerException | WebDriverException e) { return false; } } InnerHtmlContainsCondition(final String text);  InnerHtmlContainsCondition(final boolean ignoreCase, final String text); @Override boolean apply(final WebElement element); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldMatchConditionWhenInnerHtmlContainsValue() { when(mockElement.getAttribute("innerHTML")).thenReturn("<div>blah</div>"); InnerHtmlContainsCondition condition = new InnerHtmlContainsCondition("blah"); assertThat(condition.apply(mockElement), equalTo(true)); }
@Test public void shouldMatchConditionWhenInnerHtmlContainsValueIgnoringCase() { when(mockElement.getAttribute("innerHTML")).thenReturn("<div>blah</div>"); InnerHtmlContainsCondition condition = new InnerHtmlContainsCondition(true, "BlaH"); assertThat(condition.apply(mockElement), equalTo(true)); }
@Test public void shouldNotMatchConditionWhenInnerHtmlDoesNotContainValue() { when(mockElement.getAttribute("innerHTML")).thenReturn("<div>blah</div>"); InnerHtmlContainsCondition condition = new InnerHtmlContainsCondition("blsss"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleNull() { when(mockElement.getAttribute("innerHTML")).thenReturn(null); InnerHtmlContainsCondition condition = new InnerHtmlContainsCondition("blah"); assertThat(condition.apply(mockElement), equalTo(false)); }
@Test public void shouldHandleExceptionWhenElementHasStaleReference() { when(mockElement.getAttribute("innerHTML")).thenThrow(new StaleElementReferenceException("stale")); InnerHtmlContainsCondition condition = new InnerHtmlContainsCondition("blah"); assertThat(condition.apply(mockElement), equalTo(false)); }