---
title: "click(forDuration:thenDragTo:withVelocity:thenHoldForDuration:)"
framework: xcuiautomation
role: symbol
role_heading: Instance Method
path: "xcuiautomation/xcuielement/click(forduration:thendragto:withvelocity:thenholdforduration:)"
---

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

Clicks and holds an element for a duration, drags it at a velocity, and holds it over another element for a duration, all of which you specify.

## Declaration

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

## Parameters

- `duration`: The duration of the initial click and hold.
- `otherElement`: The element over which to finish the drag.
- `velocity`: The speed at which to move from the initial click 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

Discussion Specify a duration long enough to initiate a drag operation. If the element exists within a scrollable view but is offscreen, the framework attempts to scroll the element onscreen before performing the click.

## See Also

### Clicking

- [click()](xcuiautomation/xcuielement/click().md)
- [click(forDuration:thenDragTo:)](xcuiautomation/xcuielement/click(forduration:thendragto:).md)
- [doubleClick()](xcuiautomation/xcuielement/doubleclick().md)
- [rightClick()](xcuiautomation/xcuielement/rightclick().md)
