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

# element(matching:identifier:)

Matches the provided element type and identifier.

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

## Parameters

`elementType`

The element type to match.

`identifier`

An optional identifier 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).

## 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)