Contents

element

The query’s single matching element.

Declaration

var element: XCUIElement { get }

Discussion

Use the 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 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 firstMatch property instead. The firstMatch property stops traversing your app’s accessibility hierarchy as soon as it finds a matching element, speeding up element query resolution.

See Also

Related Documentation

Accessing matched elements