Touch & Gesture Actions

Touch and gesture actions for mobile and desktop interactions. Touch actions generate native touch events with humanized timing. Pointer actions (right-click, long-press) use trusted CDP input.

right_click

type: right_click
type: rightclick

Right-clicks (context menu click) on an element using trusted pointer input. Scrolls the element into view first.

ParamTypeDescription
selectorrequiredstring | arrayCSS selector for the target element.
indexoptionalnumberWhich visible match to click (0 = first). Default: 0.
timeoutoptionalnumberMax time to wait for element in ms. Default: 8000.
JSON
{ "type": "right_click", "selector": ".file-row" }

{ "type": "right_click", "selector": "#context-target", "timeout": 5000 }

long_press

type: long_press
type: longpress

Long-presses an element — pointer down, hold for a duration, then pointer up. Used for context menus on mobile, drag initiation, or any interaction that requires a sustained press.

ParamTypeDescription
selectorrequiredstring | arrayCSS selector for the target element.
durationoptionalnumberHold duration in ms. Default: 600. Alias: hold.
indexoptionalnumberWhich visible match to press (0 = first). Default: 0.
timeoutoptionalnumberMax time to wait for element in ms. Default: 8000.
JSON
{ "type": "long_press", "selector": ".menu-item", "duration": 800 }

{ "type": "long_press", "selector": "#draggable", "hold": 1000 }

touch_drag

type: touch_drag
type: touchdrag

Touch drag gesture — simulates a finger pressing down at one point, dragging to another, and lifting. The drag path is broken into discrete steps for natural movement.

ParamTypeDescription
fromXrequirednumberStart X coordinate (viewport pixels). Alias: from_x.
fromYrequirednumberStart Y coordinate (viewport pixels). Alias: from_y.
toXrequirednumberEnd X coordinate. Alias: to_x.
toYrequirednumberEnd Y coordinate. Alias: to_y.
stepsoptionalnumberNumber of intermediate touch-move events. Default: 20.
durationoptionalnumberTotal drag duration in ms. Default: 400.
JSON
// Drag slider handle to the right
{
  "type": "touch_drag",
  "fromX": 100, "fromY": 300,
  "toX": 350, "toY": 300,
  "steps": 25, "duration": 500
}

151
{
  "type": "touch_drag",
  "fromX": 200, "fromY": 500,
  "toX": 200, "toY": 150
}

swipe

type: swipe

Directional swipe gesture. Swipes from the center of the viewport in the given direction. Speed and distance control how the gesture feels.

ParamTypeDescription
directionrequiredstring"up", "down", "left", or "right". Default: "left".
distanceoptionalnumberSwipe distance in pixels. Default: 200.
speedoptionalnumberSwipe speed in ms (lower = faster). Default: 400.
JSON
{ "type": "swipe", "direction": "left", "distance": 250 }

{ "type": "swipe", "direction": "up", "distance": 400, "speed": 300 }

{ "type": "swipe", "direction": "right" }

Use Cases

  • Range sliders — touch_drag from handle to target position
  • Map navigation — touch_drag to pan, swipe for quick directional moves
  • Carousel/gallery — swipe left/right to browse items
  • Pull-to-refresh — swipe down from top of page
  • Context menus — long_press on mobile, right_click on desktop