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

# XCUICoordinate

A location on screen relative to a UI element.

```
@MainActor class XCUICoordinate
```

## Overview

Coordinates are dynamic, like the elements to which they refer, and may compute different screen locations at different times, or be invalid if the element they reference doesn’t exist.

## Topics

### Getting coordinate properties

[`referencedElement`](/documentation/XCUIAutomation/XCUICoordinate/referencedElement)

The element that the coordinate is based on, either directly or through the coordinate from which it was derived.

[`screenPoint`](/documentation/XCUIAutomation/XCUICoordinate/screenPoint)

The dynamically computed value of the coordinate’s location on screen.

### Moving the pointer

[`hover()`](/documentation/XCUIAutomation/XCUICoordinate/hover())

Moves the pointer to the coordinate.

### Clicking

[`click()`](/documentation/XCUIAutomation/XCUICoordinate/click())

Sends a click event at the coordinate.

[`click(forDuration:thenDragTo:)`](/documentation/XCUIAutomation/XCUICoordinate/click(forDuration:thenDragTo:))

Clicks and holds for a duration you specify, then drags to the other coordinate.

[`click(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)`](/documentation/XCUIAutomation/XCUICoordinate/click(forDuration:thenDragTo:withVelocity:thenHoldForDuration:))

Clicks and holds for a duration, drags at a velocity, and holds over the other coordinate for a duration, all of which you specify.

[`doubleClick()`](/documentation/XCUIAutomation/XCUICoordinate/doubleClick())

Sends a double-click event at the coordinate.

[`rightClick()`](/documentation/XCUIAutomation/XCUICoordinate/rightClick())

Sends a Control-click event at the coordinate.

### Scrolling

[`scroll(byDeltaX:deltaY:)`](/documentation/XCUIAutomation/XCUICoordinate/scroll(byDeltaX:deltaY:))

Scrolls the view by the number of x and y pixels you specify.

### Tapping and pressing

[`tap()`](/documentation/XCUIAutomation/XCUICoordinate/tap())

Sends a tap event at the coordinate.

[`doubleTap()`](/documentation/XCUIAutomation/XCUICoordinate/doubleTap())

Sends a double-tap event at the coordinate.

[`press(forDuration:)`](/documentation/XCUIAutomation/XCUICoordinate/press(forDuration:))

Initiates a press-and-hold gesture at the coordinate, holding for the duration you specify.

[`press(forDuration:thenDragTo:)`](/documentation/XCUIAutomation/XCUICoordinate/press(forDuration:thenDragTo:))

Initiates a press-and-hold gesture at the coordinate, then drags to another coordinate.

[`press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)`](/documentation/XCUIAutomation/XCUICoordinate/press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:))

Initiates a press-and-hold gesture, drags to another coordinate with a velocity you specify, and holds for a duration you specify.

### Performing gestures

[`swipeLeft()`](/documentation/XCUIAutomation/XCUICoordinate/swipeLeft())

Sends a swipe-left gesture.

[`swipeLeft(velocity:)`](/documentation/XCUIAutomation/XCUICoordinate/swipeLeft(velocity:))

Sends a swipe-left gesture with a velocity you specify.

[`swipeRight()`](/documentation/XCUIAutomation/XCUICoordinate/swipeRight())

Sends a swipe-right gesture.

[`swipeRight(velocity:)`](/documentation/XCUIAutomation/XCUICoordinate/swipeRight(velocity:))

Sends a swipe-right gesture with a velocity you specify.

[`swipeUp()`](/documentation/XCUIAutomation/XCUICoordinate/swipeUp())

Sends a swipe-up gesture.

[`swipeUp(velocity:)`](/documentation/XCUIAutomation/XCUICoordinate/swipeUp(velocity:))

Sends a swipe-up gesture with a velocity you specify.

[`swipeDown()`](/documentation/XCUIAutomation/XCUICoordinate/swipeDown())

Sends a swipe-down gesture.

[`swipeDown(velocity:)`](/documentation/XCUIAutomation/XCUICoordinate/swipeDown(velocity:))

Sends a swipe-down gesture with a velocity you specify.

### Creating relative coordinates

[`withOffset(_:)`](/documentation/XCUIAutomation/XCUICoordinate/withOffset(_:))

Creates a new coordinate with an absolute offset in points from the original coordinate.



---

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)