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

# element(matching:identifier:)

Matches the provided element type and identifier.

## Declaration

```swift
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: 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.

## See Also

### Accessing matched elements

- [allElementsBoundByAccessibilityElement](xcuiautomation/xcuielementquery/allelementsboundbyaccessibilityelement.md)
- [allElementsBoundByIndex](xcuiautomation/xcuielementquery/allelementsboundbyindex.md)
- [count](xcuiautomation/xcuielementquery/count.md)
- [element](xcuiautomation/xcuielementquery/element.md)
- [element(boundBy:)](xcuiautomation/xcuielementquery/element(boundby:).md)
- [element(matching:)](xcuiautomation/xcuielementquery/element(matching:).md)
- [subscript(_:)](xcuiautomation/xcuielementquery/subscript(_:).md)
- [element(at:)](xcuiautomation/xcuielementquery/element(at:).md)
