---
title: XCUIElement
framework: xcuiautomation
role: symbol
role_heading: Class
path: xcuiautomation/xcuielement
---

# XCUIElement

A UI element in an application.

## Declaration

```swift
@MainActor class XCUIElement
```

## Overview

Overview 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. note: XCUIElement adopts the XCUIElementAttributes protocol, which provides additional properties for querying the current state of a UI element’s attributes.

## Topics

### Querying element state

- [waitForExistence(timeout:)](xcuiautomation/xcuielement/waitforexistence(timeout:).md)
- [waitForNonExistence(timeout:)](xcuiautomation/xcuielement/waitfornonexistence(timeout:).md)
- [wait(for:toEqual:timeout:)](xcuiautomation/xcuielement/wait(for:toequal:timeout:).md)
- [exists](xcuiautomation/xcuielement/exists.md)
- [isHittable](xcuiautomation/xcuielement/ishittable.md)
- [debugDescription](xcuiautomation/xcuielement/debugdescription.md)

### Querying descendant elements

- [children(matching:)](xcuiautomation/xcuielement/children(matching:).md)
- [descendants(matching:)](xcuiautomation/xcuielement/descendants(matching:).md)

### Typing text

- [typeText(_:)](xcuiautomation/xcuielement/typetext(_:).md)

### Combining keystrokes

- [typeKey(_:modifierFlags:)](xcuiautomation/xcuielement/typekey(_:modifierflags:)-6gaoi.md)
- [typeKey(_:modifierFlags:)](xcuiautomation/xcuielement/typekey(_:modifierflags:)-9ubn.md)
- [XCUIKeyboardKey](xcuiautomation/xcuikeyboardkey.md)
- [perform(withKeyModifiers:block:)](xcuiautomation/xcuielement/perform(withkeymodifiers:block:).md)
- [XCUIElement.KeyModifierFlags](xcuiautomation/xcuielement/keymodifierflags.md)

### Moving the pointer

- [hover()](xcuiautomation/xcuielement/hover().md)

### Clicking

- [click()](xcuiautomation/xcuielement/click().md)
- [click(forDuration:thenDragTo:)](xcuiautomation/xcuielement/click(forduration:thendragto:).md)
- [click(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)](xcuiautomation/xcuielement/click(forduration:thendragto:withvelocity:thenholdforduration:).md)
- [doubleClick()](xcuiautomation/xcuielement/doubleclick().md)
- [rightClick()](xcuiautomation/xcuielement/rightclick().md)

### Scrolling

- [scroll(byDeltaX:deltaY:)](xcuiautomation/xcuielement/scroll(bydeltax:deltay:).md)

### Tapping and pressing

- [tap()](xcuiautomation/xcuielement/tap().md)
- [doubleTap()](xcuiautomation/xcuielement/doubletap().md)
- [press(forDuration:)](xcuiautomation/xcuielement/press(forduration:).md)
- [press(forDuration:thenDragTo:)](xcuiautomation/xcuielement/press(forduration:thendragto:).md)
- [press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)](xcuiautomation/xcuielement/press(forduration:thendragto:withvelocity:thenholdforduration:).md)

### Tapping multiple times

- [twoFingerTap()](xcuiautomation/xcuielement/twofingertap().md)
- [tap(withNumberOfTaps:numberOfTouches:)](xcuiautomation/xcuielement/tap(withnumberoftaps:numberoftouches:).md)

### Performing gestures

- [swipeLeft()](xcuiautomation/xcuielement/swipeleft().md)
- [swipeLeft(velocity:)](xcuiautomation/xcuielement/swipeleft(velocity:).md)
- [swipeRight()](xcuiautomation/xcuielement/swiperight().md)
- [swipeRight(velocity:)](xcuiautomation/xcuielement/swiperight(velocity:).md)
- [swipeUp()](xcuiautomation/xcuielement/swipeup().md)
- [swipeUp(velocity:)](xcuiautomation/xcuielement/swipeup(velocity:).md)
- [swipeDown()](xcuiautomation/xcuielement/swipedown().md)
- [swipeDown(velocity:)](xcuiautomation/xcuielement/swipedown(velocity:).md)
- [pinch(withScale:velocity:)](xcuiautomation/xcuielement/pinch(withscale:velocity:).md)
- [rotate(_:withVelocity:)](xcuiautomation/xcuielement/rotate(_:withvelocity:).md)
- [XCUIGestureVelocity](xcuiautomation/xcuigesturevelocity.md)

### Interacting with sliders

- [normalizedSliderPosition](xcuiautomation/xcuielement/normalizedsliderposition.md)
- [adjust(toNormalizedSliderPosition:)](xcuiautomation/xcuielement/adjust(tonormalizedsliderposition:).md)

### Interacting with pickers

- [adjust(toPickerWheelValue:)](xcuiautomation/xcuielement/adjust(topickerwheelvalue:).md)

### Calculating coordinates

- [coordinate(withNormalizedOffset:)](xcuiautomation/xcuielement/coordinate(withnormalizedoffset:).md)

### Supporting types

- [XCUIElement.ElementType](xcuiautomation/xcuielement/elementtype.md)
- [XCUIElement.SizeClass](xcuiautomation/xcuielement/sizeclass.md)
- [XCUIElement.AttributeName](xcuiautomation/xcuielement/attributename.md)

### Deprecated methods

- [swipeDown(withVelocity:)](xcuiautomation/xcuielement/swipedown(withvelocity:).md)
- [swipeUp(withVelocity:)](xcuiautomation/xcuielement/swipeup(withvelocity:).md)
- [swipeLeft(withVelocity:)](xcuiautomation/xcuielement/swipeleft(withvelocity:).md)
- [swipeRight(withVelocity:)](xcuiautomation/xcuielement/swiperight(withvelocity:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [XCUIApplication](xcuiautomation/xcuiapplication.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [XCUIElementAttributes](xcuiautomation/xcuielementattributes.md)
- [XCUIElementSnapshotProviding](xcuiautomation/xcuielementsnapshotproviding.md)
- [XCUIElementTypeQueryProvider](xcuiautomation/xcuielementtypequeryprovider.md)
- [XCUIScreenshotProviding](xcuiautomation/xcuiscreenshotproviding.md)

## See Also

### UI elements

- [XCUIElementAttributes](xcuiautomation/xcuielementattributes.md)
- [XCUIElementSnapshot](xcuiautomation/xcuielementsnapshot.md)
- [XCUIElementSnapshotProviding](xcuiautomation/xcuielementsnapshotproviding.md)
- [XCUICoordinate](xcuiautomation/xcuicoordinate.md)
