Class

XCUICoordinate

A location on screen relative to some UI element.

Declaration

class XCUICoordinate : NSObject

Overview

Coordinates are dynamic, just like the elements to which they refer, and may compute different screen locations at different times, or be invalid if the referenced element does not exist.

Topics

Coordinate Properties

var referencedElement: XCUIElement

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

var screenPoint: CGPoint

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

Moving the Cursor

Available on macOS only.

func hover()

Moves the cursor to the coordinate.

Clicking

Available on macOS only.

func click()

Sends a click event at the coordinate.

func click(forDuration: TimeInterval, thenDragTo: XCUICoordinate)

Clicks and holds for a specified duration (generally long enough to start a drag operation) then drags to the other coordinate.

func doubleClick()

Sends a double click event at the coordinate.

func rightClick()

Sends a right click event at the coordinate.

Scrolling

Available on macOS only.

func scroll(byDeltaX: CGFloat, deltaY: CGFloat)

Scrolls the view by the specified number of x and y pixels.

Tapping and Pressing

Available on iOS, and on macOS for Touch Bar interactions.

func tap()

Sends a tap event at the coordinate.

func doubleTap()

Sends a double tap event at the coordinate.

func press(forDuration: TimeInterval)

Sends a long press gesture at the coordinate, holding for the specified duration.

func press(forDuration: TimeInterval, thenDragTo: XCUICoordinate)

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

Creating Relative Coordinates

func withOffset(CGVector) -> XCUICoordinate

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

Relationships

Inherits From

See Also

UI Elements

class XCUIElement

A UI element in an application.

protocol XCUIElementAttributes

Attributes exposed by UI elements.