@Test
public void hasAttributeTest() {

    Path el = div.that(hasAttribute("foo", "bar"));
    String xpath = el.getXPath().get();
    NodeList nodes = findAllByXpath("<div class=\"abc\" foo=\"bar\"></div><div class=\" foo \"></div><span class=\" foo \">abc</span>", el);
    assertThat(nodes.getLength(), is(1));
    assertThat(getCssClass(nodes.item(0)), equalTo("abc"));
    assertThat(getElementName(nodes.item(0)), equalTo("div"));
    assertThat(el.toString(), is(equalTo("div, that has foo: \"bar\"")));
}