---
title: "descendants(matching:)"
framework: xcuiautomation
role: symbol
role_heading: Instance Method
path: "xcuiautomation/xcuielement/descendants(matching:)"
---

# descendants(matching:)

Returns a query for all descendants of the element matching the type you specify.

## Declaration

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

## Discussion

Discussion Because XCUIElement 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 table.descendants(matching: .cell), you can use the cells property from the protocol to retrieve table.cells.

## See Also

### Querying descendant elements

- [children(matching:)](xcuiautomation/xcuielement/children(matching:).md)
