hubcap scrollto — Scroll an element into view

When to use

Scroll an element into view. Use before click if the element is off-screen. Use scroll for pixel-based scrolling.

Usage

hubcap scrollto <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the element to scroll into view

Flags

None.

Output

FieldTypeDescription
scrolledbooleanWhether the scroll succeeded
selectorstringThe selector that was used
{"scrolled":true,"selector":"#footer"}

Errors

ConditionExit codeStderr
Element not found1error: JS exception: <message>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Scroll to the footer:

hubcap scrollto '#footer'

Scroll an element into view, then click it:

hubcap scrollto '.load-more' && hubcap click '.load-more'

See also