<!--
{
  "availability" : [
    "Xcode: 16.3.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "XCUIAutomation",
  "identifier" : "/documentation/XCUIAutomation/XCUIElement/press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XCUIAutomation"
    ],
    "preciseIdentifier" : "c:objc(cs)XCUIElement(im)pressForDuration:thenDragToElement:withVelocity:thenHoldForDuration:"
  },
  "title" : "press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)"
}
-->

# press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)

Initiates a press-and-hold gesture, drags to another element at a velocity, and holds for a duration, all of which you specify.

```
func press(forDuration duration: TimeInterval, thenDragTo otherElement: XCUIElement, withVelocity velocity: XCUIGestureVelocity, thenHoldForDuration holdDuration: TimeInterval)
```

## Parameters

`duration`

The duration of the initial press-and-hold gesture.

`otherElement`

The element over which to finish the drag gesture.

`velocity`

The speed at which to move from the initial press position to the other element, expressed in pixels per second.

`holdDuration`

The duration for which to hold the dragged element over the other element.

## Discussion

---

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)