コード例 #1
0
  @Test
  public void isNotSatisfiedIfWebElementNotLocated() {

    context.checking(
        new Expectations() {
          {
            oneOf(element).find();
            will(returnValue(null));
          }
        });

    probe.doProbe();
    assertThat(probe.isSatisfied(), is(false));
  }
コード例 #2
0
  @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));
  }
コード例 #3
0
  @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));
  }
コード例 #4
0
  @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 "));
  }