hubcap clickat

Click at specific page coordinates.

When to use

Click at exact viewport coordinates when you know the pixel position. Use click when you have a CSS selector instead. Use bounds to get an element’s coordinates first.

Usage

hubcap clickat <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
clickedbooleanWhether the click succeeded
xnumberThe X coordinate that was clicked
ynumberThe Y coordinate that was clicked
{"clicked":true,"x":100,"y":200}

Errors

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

Examples

Click at the center of a 1280x720 viewport:

hubcap clickat 640 360

Click near the top-left corner:

hubcap clickat 10 10

Get an element’s position with bounds, then click it:

hubcap bounds '#submit' | jq '{x: .x, y: .y}' | xargs -I {} sh -c 'hubcap clickat $(echo {} | jq -r ".x") $(echo {} | jq -r ".y")'

See also

  • click - Click an element by CSS selector
  • mouse - Move mouse to coordinates without clicking
  • bounds - Get element bounding box coordinates
  • hover - Hover over an element by selector