hubcap value — Get the value of an input element

When to use

Get the current value of an input, textarea, or select element. Use text for non-form elements. Use setvalue to change the value.

Usage

hubcap value <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the input, textarea, or select element

Flags

None.

Output

FieldTypeDescription
selectorstringThe selector that was used
valuestringThe current value of the element
{"selector":"#email","value":"user@example.com"}

Errors

ConditionExit codeStderr
Element not found1error: selector "<sel>": element not found
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Get the value of an email input:

hubcap value '#email'

Fill an input, then verify its value:

hubcap fill '#email' 'test@example.com' && hubcap value '#email' | jq -r '.value'

See also

  • text - Get inner text of an element
  • setvalue - Set the value directly
  • fill - Focus, clear, and type in one step
  • attr - Get an attribute of an element