hubcap drag

Drag one element onto another.

When to use

Use drag to simulate a drag-and-drop interaction between two elements. Both the source and destination selectors must match visible elements. Use mouse for more granular pointer control when the standard drag gesture is not sufficient.

Usage

hubcap drag <source-selector> <dest-selector>

Arguments

ArgumentTypeRequiredDescription
source-selectorstringYesCSS selector of the element to drag
dest-selectorstringYesCSS selector of the drop target

Flags

None.

Output

FieldTypeDescription
draggedbooleanWhether the drag succeeded
sourcestringThe selector of the dragged element
deststringThe selector of the drop target
{"dragged":true,"source":"#item-1","dest":"#dropzone"}

Errors

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

Examples

Drag a list item to a drop zone:

hubcap drag '#item-1' '#dropzone'

Reorder items in a sortable list:

hubcap drag '.sortable:first-child' '.sortable:last-child'

Drag an item then verify the drop zone updated:

hubcap drag '#card' '#done-column' && hubcap text '#done-column'

See also

  • click - Click an element
  • mouse - Move the mouse to coordinates
  • hover - Hover over an element