DomMatchers


public final class DomMatchers


A collection of hamcrest matchers for objects in the org.w3c.dom package (such as and Element).

Summary

Public methods

static Matcher<Document>

Returns a matcher that matches Documents that have a body containing the given text.

static Matcher<Document>
elementById(String id, Matcher<Element> elementMatcher)

Matches Documents that have an Element with the given id that matches the given element matcher.

static Matcher<Document>
elementByXPath(String xpath, Matcher<Element> elementMatcher)

Matches a XPath and validates it against the first Element that it finds in the .

static Matcher<Document>

Returns a matcher that matches Documents that have at least one element with the given id.

static Matcher<Document>

Returns a matcher that matches Documents that have at least one element with the given xpath.

static Matcher<Document>
withBody(Matcher<Element> bodyMatcher)

Returns a matcher that matches Documents with body that matches the given matcher.

static Matcher<Element>
withTextContent(String textContent)

Returns a matcher that matches Elements with the given textContent.

static Matcher<Element>
withTextContent(Matcher<String> textContentMatcher)

Returns a matcher that matches Elements that have textContent matching the given matcher.

Public methods

containingTextInBody

public static Matcher<DocumentcontainingTextInBody(String text)

Returns a matcher that matches Documents that have a body containing the given text.

elementById

public static Matcher<DocumentelementById(String id, Matcher<Element> elementMatcher)

Matches Documents that have an Element with the given id that matches the given element matcher.

elementByXPath

public static Matcher<DocumentelementByXPath(String xpath, Matcher<Element> elementMatcher)

Matches a XPath and validates it against the first Element that it finds in the .

hasElementWithId

public static Matcher<DocumenthasElementWithId(String id)

Returns a matcher that matches Documents that have at least one element with the given id.

hasElementWithXpath

public static Matcher<DocumenthasElementWithXpath(String xpath)

Returns a matcher that matches Documents that have at least one element with the given xpath.

withBody

public static Matcher<DocumentwithBody(Matcher<Element> bodyMatcher)

Returns a matcher that matches Documents with body that matches the given matcher.

withTextContent

public static Matcher<ElementwithTextContent(String textContent)

Returns a matcher that matches Elements with the given textContent. Equivalent of withTextContent(is(textContent)).

withTextContent

public static Matcher<ElementwithTextContent(Matcher<String> textContentMatcher)

Returns a matcher that matches Elements that have textContent matching the given matcher.