@Test
public void isAfterAtMostN() {

    Path el = div.that(isAfter(atMost(2).occurrencesOf(div.that(hasSomeText))));
    String xpath = el.getXPath().get();
    NodeList nodes = findAllByXpath("<div>a</div><div class='b'><div>a.a</div><div>a.b</div><div>a.c</div></div><div>c</div>", el);
    assertThat(nodes.getLength(), is(4));
    assertThat(getText(nodes.item(0)), equalTo("a"));
    assertThat(getCssClass(nodes.item(1)), equalTo("b"));
    assertThat(getText(nodes.item(2)), equalTo("a.a"));
    assertThat(getText(nodes.item(3)), equalTo("a.b"));
    assertThat(el.toString(), is(equalTo("div, that is after at most 2 occurrences of: (div, that has some text)")));
}