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

# matching(_:identifier:)

Returns a new query that matches elements of the requested type and have an identifying property that matches a provided identifier.

## Declaration

```swift
func matching(_ elementType: XCUIElement.ElementType, identifier: String?) -> XCUIElementQuery
```

## Parameters

- `elementType`: The element type to match.
- `identifier`: An optional string to match against any one of each element’s identifying properties: doc://com.apple.xcuiautomation/documentation/XCUIAutomation/XCUIElementAttributes/identifier, doc://com.apple.xcuiautomation/documentation/XCUIAutomation/XCUIElementAttributes/title, doc://com.apple.xcuiautomation/documentation/XCUIAutomation/XCUIElementAttributes/label, doc://com.apple.xcuiautomation/documentation/XCUIAutomation/XCUIElementAttributes/value, or doc://com.apple.xcuiautomation/documentation/XCUIAutomation/XCUIElementAttributes/placeholderValue.

## Return Value

Return Value A new query that defines a search that extends the search criteria of the receiver. The new search matches elements that match the original search of the requested type that have an identifying property matching a provided identifier. For the list of the types, see XCUIElement.ElementType.

## See Also

### Creating new queries

- [children(matching:)](xcuiautomation/xcuielementquery/children(matching:).md)
- [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)
