@Test
public void withIndexTest() {

    Path el = div.that(isWithIndex(1));
    String xpath = el.getXPath().get();
    NodeList nodes = findAllByXpath("<div>a</div><div>b</div><div>c</div><div>d</div><span>abc</span>", el);
    assertThat(nodes.getLength(), is(1));
    assertThat(getText(nodes.item(0)), equalTo("b"));
    assertThat(getElementName(nodes.item(0)), equalTo("div"));
    assertThat(el.toString(), is(equalTo("div, with index 1")));
}