---
title: "press(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)"
framework: xcuiautomation
role: symbol
role_heading: Instance Method
path: "xcuiautomation/xcuielement/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.

## Declaration

```swift
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.

## See Also

### 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)
