<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIElementQuery/matching(_:identifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:objc(cs)XCUIElementQuery(im)matchingType:identifier:"
  },
  "title" : "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.

```
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: [`identifier`](/documentation/XCUIAutomation/XCUIElementAttributes/identifier), [`title`](/documentation/XCUIAutomation/XCUIElementAttributes/title), [`label`](/documentation/XCUIAutomation/XCUIElementAttributes/label), [`value`](/documentation/XCUIAutomation/XCUIElementAttributes/value), or [`placeholderValue`](/documentation/XCUIAutomation/XCUIElementAttributes/placeholderValue).

## 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`](/documentation/XCUIAutomation/XCUIElement/ElementType).

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)