---
title: "subscript(_:)"
framework: xcuiautomation
role: symbol
role_heading: Instance Subscript
path: "xcuiautomation/xcuielementquery/subscript(_:)"
---

# subscript(_:)

Returns a descendant element that matches a provided identifier.

## Declaration

```swift
subscript(key: String) -> XCUIElement { get }
```

## Parameters

- `key`: A 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)
- [element(matching:identifier:)](xcuiautomation/xcuielementquery/element(matching:identifier:).md)
- [element(at:)](xcuiautomation/xcuielementquery/element(at:).md)
