hubcap mouse

Move the mouse to specific viewport coordinates without clicking.

When to use

Move the mouse pointer to exact coordinates without triggering a click. Use hover to move to an element by CSS selector. Use clickat to move and click in one step.

Usage

hubcap mouse <x> <y>

Arguments

ArgumentTypeRequiredDescription
xfloatYesX coordinate in pixels from the left edge of the viewport
yfloatYesY coordinate in pixels from the top edge of the viewport

Flags

None.

Output

FieldTypeDescription
xnumberThe X coordinate the mouse moved to
ynumberThe Y coordinate the mouse moved to
{"x":100,"y":200}

Errors

ConditionExit codeStderr
Invalid x coordinate1invalid x coordinate: ...
Invalid y coordinate1invalid y coordinate: ...
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Move the mouse to the center of the viewport:

hubcap mouse 640 360

Move the mouse to trigger a hover effect at a specific point:

hubcap mouse 250 75

Move to an element’s position using bounds, then take a screenshot of the hover state:

pos=$(hubcap bounds '.tooltip-trigger' | jq -r '"\(.x) \(.y)"') && hubcap mouse $pos && hubcap screenshot hover.png

See also

  • clickat - Click at specific coordinates
  • hover - Hover over an element by CSS selector
  • drag - Drag from one element to another
  • bounds - Get element bounding box coordinates