Class

XCUIElementQuery

A query for locating UI elements.

Declaration

class XCUIElementQuery : NSObject

Topics

Creating New Queries

func children(matching: XCUIElement.ElementType) -> XCUIElementQuery

Returns a new query that matches all direct children of the requested type.

func descendants(matching: XCUIElement.ElementType) -> XCUIElementQuery

Returns a new query that matches all descendants of the requested type.

func containing(NSPredicate) -> XCUIElementQuery

Returns a new query that matches all elements containing a descendant that matches the provided predicate.

func containing(XCUIElement.ElementType, identifier: String?) -> XCUIElementQuery

Returns a new query that matches all elements containing an element of the requested type, optionally also matching a specified identifier.

func matching(identifier: String) -> XCUIElementQuery

Returns a new query that matches all elements with the provided identifier.

func matching(NSPredicate) -> XCUIElementQuery

Returns a new query that matches all elements directly matching the provided predicate.

func matching(XCUIElement.ElementType, identifier: String?) -> XCUIElementQuery

Returns a new query that matches all elements of the requested type, optionally also matching a specific identifier.

Accessing Matched Elements

var allElementsBoundByAccessibilityElement: [XCUIElement]

Immediately evaluates the query and returns an array of elements bound to the resulting accessibility elements.

var allElementsBoundByIndex: [XCUIElement]

Immediately evaluates the query and returns an array of elements bound by the index of each result.

var count: Int

Evaluates the query and returns the number of elements that match.

var element: XCUIElement

The query’s single matching element.

func element(boundBy: Int) -> XCUIElement

An element that uses an index into the query’s results to determine which underlying accessibility element to use.

func element(matching: NSPredicate) -> XCUIElement

An element that matches the predicate.

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

An element that matches the provided element type and identifier.

subscript(String) -> XCUIElement

Returns a descendant element matching the identifier specified by key.

func element(at: Int) -> XCUIElement

Returns an element that will resolve to the index into the query’s result set.

Deprecated

Debugging Element Queries

var debugDescription: String

Provides debugging information about the query.

Window Button Identifiers

Identifiers used to find the default system buttons for modifying a window's size and full screen state.

let XCUIIdentifierCloseWindow: String

The identifier for a window’s “close” button.

let XCUIIdentifierFullScreenWindow: String

The identifier for a window’s “full screen” button.

let XCUIIdentifierMinimizeWindow: String

The identifier for a window’s “minimize” button.

let XCUIIdentifierZoomWindow: String

The identifier for a window’s “zoom” button.

See Also

UI Element Queries

protocol XCUIElementTypeQueryProvider

Provides ready-made queries for locating descendant UI elements.