hubcap visible — Check if an element is visible

When to use

Check if an element is visible (not hidden by CSS). Use exists to check DOM presence regardless of visibility.

Usage

hubcap visible <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the element to check

Flags

None.

Output

FieldTypeDescription
visiblebooleanWhether the element is visible
selectorstringThe selector that was used
{"visible":true,"selector":".modal"}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Check if a modal is visible:

hubcap visible '.modal'

Wait for an element, then check visibility:

hubcap wait '.toast' && hubcap visible '.toast' | jq -r '.visible'

See also

  • exists - Check if an element exists in the DOM
  • count - Count matching elements
  • bounds - Get element bounding box
  • wait - Wait for an element to appear