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

# press(forDuration:thenDragTo:)

Initiates a press-and-hold gesture, then drags to another element.

```
func press(forDuration duration: TimeInterval, thenDragTo otherElement: XCUIElement)
```

## Parameters

`duration`

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

`otherElement`

The element over which to finish the drag. For example, when reordering table cells, this element is the reorder icon of the destination row.

## Discussion

This interaction is suitable for table-cell reordering and similar operations.

---

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)