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

# click(forDuration:thenDragTo:)

Clicks and holds an element for a duration you specify, and then drags it to another element.

## Declaration

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

## Parameters

- `duration`: The duration of the initial click and hold.
- `otherElement`: The element over which to finish the drag.

## 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:withVelocity:thenHoldForDuration:)](xcuiautomation/xcuielement/click(forduration:thendragto:withvelocity:thenholdforduration:).md)
- [doubleClick()](xcuiautomation/xcuielement/doubleclick().md)
- [rightClick()](xcuiautomation/xcuielement/rightclick().md)
