drag

suspend fun drag(fromX: Double, fromY: Double, toX: Double, toY: Double, durationMs: Long = 300)

Performs a physical touch or mouse drag gesture from (fromX, fromY) to (toX, toY) over durationMs.

Example Usage

drag(fromX = 100.0, fromY = 500.0, toX = 100.0, toY = 100.0, durationMs = 400L)

Parameters

fromX

Starting X pixel coordinate.

fromY

Starting Y pixel coordinate.

toX

Ending X pixel coordinate.

toY

Ending Y pixel coordinate.

durationMs

Gesture movement duration in milliseconds (default 300ms).


suspend fun drag(tag: String, offsetX: Double, offsetY: Double, durationMs: Long = 300)

Drags the UI element matching string tag by moving it by (offsetX, offsetY) pixels.

Example Usage

drag("volume_slider", offsetX = 50.0, offsetY = 0.0)

Parameters

tag

The testTag string or visible text of the element to drag.

offsetX

Horizontal pixel movement offset.

offsetY

Vertical pixel movement offset.

durationMs

Gesture duration in milliseconds (default 300ms).


suspend fun drag(selector: Selector, offsetX: Double, offsetY: Double, durationMs: Long = 300)

Drags the UI element matching selector by moving it by (offsetX, offsetY) pixels.

Advanced variant using explicit selectors.

Example Usage

drag(tag("thumb_handle"), offsetX = 100.0, offsetY = 0.0)

Parameters

selector

Explicit selector targeting the element to drag.

offsetX

Horizontal pixel movement offset.

offsetY

Vertical pixel movement offset.

durationMs

Gesture duration in milliseconds (default 300ms).