@Test
public void hasAggregatedTextContainsTest() {

    Path el = div.that(hasAggregatedTextContaining("X Y"));
    String xpath = el.getXPath().get();
    NodeList nodes = findAllByXpath("<div>x   yz</div><div><span>zx </span><div>Yy</div></div><span>abc</span>", el);
    assertThat(nodes.getLength(), is(2));
    assertThat(getText(nodes.item(0)), equalTo("x   yz"));
    assertThat(getText(nodes.item(1).getFirstChild()), equalTo("zx "));
    assertThat(el.toString(), is(equalTo("div, with aggregated text containing \"X Y\"")));
}