@Test public void isNotSatisfiedIfWebElementNotLocated() { context.checking( new Expectations() { { oneOf(element).find(); will(returnValue(null)); } }); probe.doProbe(); assertThat(probe.isSatisfied(), is(false)); }
@Test public void isSatisfiedIfWebElementHasBeenLocatedAndMatcherMatches() { final WebElement webElement = context.mock(WebElement.class); context.checking( new Expectations() { { oneOf(element).find(); will(returnValue(webElement)); oneOf(elementMatcher).matches(webElement); will(returnValue(true)); } }); probe.doProbe(); assertThat(probe.isSatisfied(), is(true)); }
@Test public void isNotSatisfiedIfMatcherDoesNotMatch() { final WebElement webElement = context.mock(WebElement.class); context.checking( new Expectations() { { oneOf(element).find(); will(returnValue(webElement)); oneOf(elementMatcher).matches(webElement); will(returnValue(false)); } }); probe.doProbe(); assertThat(probe.isSatisfied(), is(false)); }
@Test public void displaysCorrectFailureDescriptionForProbeWhenElementDoesNotMatch() { final StringDescription description = new StringDescription(); final WebElement webElement = context.mock(WebElement.class); context.checking( new Expectations() { { oneOf(element).find(); will(returnValue(webElement)); oneOf(elementMatcher).describeTo(description); } }); probe.doProbe(); probe.describeFailureTo(description); assertThat(description.toString(), is("The element does not match ")); }