hubcap scroll

Scroll the page by a relative pixel amount.

When to use

Scroll the page by a given number of pixels on the x and y axes. Use scrollto to scroll a specific element into view. Use scrolltop or scrollbottom to jump to the top or bottom of the page.

Usage

hubcap scroll <x> <y>

Arguments

ArgumentTypeRequiredDescription
xintYesHorizontal scroll distance in pixels (positive = right, negative = left)
yintYesVertical scroll distance in pixels (positive = down, negative = up)

Flags

None.

Output

FieldTypeDescription
scrolledbooleanWhether the scroll was performed
xnumberHorizontal distance scrolled
ynumberVertical distance scrolled
{"scrolled":true,"x":0,"y":500}

Errors

ConditionExit codeStderr
Invalid x value1invalid x value: <val>
Invalid y value1invalid y value: <val>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Scroll down 500 pixels:

hubcap scroll 0 500

Scroll right 200 pixels:

hubcap scroll 200 0

Scroll diagonally:

hubcap scroll 100 300

Scroll down and take a screenshot of the newly visible content:

hubcap scroll 0 800 && hubcap screenshot --output after-scroll.png

See also