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

# element

The query’s single matching element.

```
var element: XCUIElement { get }
```

## Discussion

Use the [`element`](/documentation/XCUIAutomation/XCUIElementQuery/element) property to access a query’s result when you expect a single matching element for the query, but want to check for multiple ambiguous matches before accessing the result. The [`element`](/documentation/XCUIAutomation/XCUIElementQuery/element) property traverses your app’s accessibility tree to check for multiple matching elements before returning, and fails the current test if there isn’t a single matching element.

In cases where you know categorically that there’s a single matching element, use the [`XCUIElementTypeQueryProvider`](/documentation/XCUIAutomation/XCUIElementTypeQueryProvider) [`firstMatch`](/documentation/XCUIAutomation/XCUIElementTypeQueryProvider/firstMatch) property instead. The [`firstMatch`](/documentation/XCUIAutomation/XCUIElementTypeQueryProvider/firstMatch) property stops traversing your app’s accessibility hierarchy as soon as it finds a matching element, speeding up element query resolution.

## See Also

[`firstMatch`](/documentation/XCUIAutomation/XCUIElementTypeQueryProvider/firstMatch)

The first element that matches the query.



---

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)