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

# children(matching:)

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

## Declaration

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

## Parameters

- `type`: The element type to match.

## Return Value

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

## Discussion

Discussion If you need to match all descendants including elements that aren’t direct child elements, use the descendants(matching:) method.

## See Also

### Creating new queries

- [descendants(matching:)](xcuiautomation/xcuielementquery/descendants(matching:).md)
- [containing(_:)](xcuiautomation/xcuielementquery/containing(_:).md)
- [containing(_:identifier:)](xcuiautomation/xcuielementquery/containing(_:identifier:).md)
- [matching(identifier:)](xcuiautomation/xcuielementquery/matching(identifier:).md)
- [matching(_:)](xcuiautomation/xcuielementquery/matching(_:).md)
- [matching(_:identifier:)](xcuiautomation/xcuielementquery/matching(_:identifier:).md)
