hubcap swipe

Perform a touch swipe gesture on an element.

When to use

Use swipe to simulate a directional touch swipe for mobile emulation testing. Use scroll for desktop-style pixel scrolling instead. Pair with emulate to set a mobile device profile for full mobile simulation.

Usage

hubcap swipe <selector> <direction>

Arguments

ArgumentTypeRequiredDescription
selectorstringYesCSS selector of the element to swipe on
directionstringYesSwipe direction: left, right, up, or down

Flags

None.

Output

FieldTypeDescription
swipedbooleanWhether the swipe succeeded
directionstringThe swipe direction that was performed
selectorstringThe selector that was swiped
{"swiped":true,"direction":"left","selector":".carousel"}

Errors

ConditionExit codeStderr
Element not found1error: element not found: <sel>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Swipe left on a carousel:

hubcap swipe '.carousel' left

Swipe down to refresh:

hubcap swipe '#feed' down

Dismiss a notification by swiping right:

hubcap swipe '.notification' right

Emulate a mobile device then swipe through a gallery:

hubcap emulate 'iPhone 14' && hubcap swipe '.gallery' left && hubcap swipe '.gallery' left

See also

  • pinch - Pinch zoom gesture
  • tap - Touch tap gesture
  • scroll - Desktop pixel scrolling
  • emulate - Emulate a mobile device