XCUIElement
A UI element in an application.
Declaration
@MainActor class XCUIElementOverview
In macOS and iPadOS 15 and later, XCUIElement provides a way to test your app with keyboard and mouse interactions, such as typing, clicking, scrolling, and moving and pausing the pointer. In iOS, XCUIElement provides a way to test your app with gestures, such as tapping, swiping, pinching, and rotating.
Topics
Querying element state
waitForExistence(timeout:)waitForNonExistence(timeout:)wait(for:toEqual:timeout:)existsisHittabledebugDescription
Querying descendant elements
Typing text
Combining keystrokes
typeKey(_:modifierFlags:)typeKey(_:modifierFlags:)XCUIKeyboardKeyperform(withKeyModifiers:block:)XCUIElement.KeyModifierFlags
Moving the pointer
Clicking
click()click(forDuration:thenDragTo:)click(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)doubleClick()rightClick()
Scrolling
Tapping and pressing
tap()doubleTap()press(forDuration:)press(forDuration:thenDragTo:)press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)
Tapping multiple times
Performing gestures
swipeLeft()swipeLeft(velocity:)swipeRight()swipeRight(velocity:)swipeUp()swipeUp(velocity:)swipeDown()swipeDown(velocity:)pinch(withScale:velocity:)rotate(_:withVelocity:)XCUIGestureVelocity