Contents

descendants(matching:)

Returns a new query that matches all descendants of the requested type.

Declaration

func descendants(matching type: XCUIElement.ElementType) -> XCUIElementQuery

Parameters

  • type:

    The element type to match.

Return Value

A new query that defines a search that extends the search criteria of the receiver. The new search finds all decendant of elements that match the original search and are of the requested type. For a list of the types, see XCUIElement.ElementType.

Discussion

Because XCUIElementQuery conforms to the XCUIElementTypeQueryProvider protocol, you can use the protocol’s properties as shorthand for calling descendants(matching:) for different element types. For example, rather than calling query.descendants(matching: .button), you can use the buttons property from the protocol to retrieve query.buttons.

See Also

Creating new queries