@Test
public void hasNChildrenAtMost() {

    Path el = div.or(span).that(hasNChildren(3).orLess());
    String xpath = el.getXPath().get();
    NodeList nodes = findAllByXpath("<div><x/>foo</div><div>foo</div><span><a/><b/></span>", el);
    assertThat(nodes.getLength(), is(3));
    assertThat(getElementName(nodes.item(0)), equalTo("div"));
    assertThat(getElementName(nodes.item(1)), equalTo("div"));
    assertThat(getElementName(nodes.item(2)), equalTo("span"));
    assertThat(el.toString(), is(equalTo("div or span, that has at most 3 children")));
}