Skip to content

Most visited

Recently visited

navigation

DomMatchers

public final class DomMatchers
extends Object

java.lang.Object
   ↳ android.support.test.espresso.web.matcher.DomMatchers


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

Summary

Public methods

static Matcher<Document> containingTextInBody(String text)

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

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 NodeList.

static Matcher<Document> hasElementWithId(String id)

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

static Matcher<Document> hasElementWithXpath(String xpath)

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.

Inherited methods

From class java.lang.Object

Public methods

containingTextInBody

Matcher<Document> containingTextInBody (String text)

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

Parameters
text String

Returns
Matcher<Document>

elementById

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

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

Parameters
id String

elementMatcher Matcher

Returns
Matcher<Document>

elementByXPath

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

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

Parameters
xpath String

elementMatcher Matcher

Returns
Matcher<Document>

hasElementWithId

Matcher<Document> hasElementWithId (String id)

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

Parameters
id String

Returns
Matcher<Document>

hasElementWithXpath

Matcher<Document> hasElementWithXpath (String xpath)

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

Parameters
xpath String

Returns
Matcher<Document>

withBody

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

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

Parameters
bodyMatcher Matcher

Returns
Matcher<Document>

withTextContent

Matcher<Element> withTextContent (String textContent)

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

Parameters
textContent String

Returns
Matcher<Element>

withTextContent

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

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

Parameters
textContentMatcher Matcher

Returns
Matcher<Element>

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)