hubcap clear — Clear an input field

When to use

Clear an input field. Use fill to clear and type new text in one step. Use setvalue to set the value directly without simulating key events.

Usage

hubcap clear <selector>

Arguments

ArgumentTypeRequiredDescription
selectorstringyesCSS selector of the input to clear

Flags

None.

Output

FieldTypeDescription
clearedbooleanWhether the clear succeeded
selectorstringThe selector that was used
{"cleared":true,"selector":"#search"}

Errors

ConditionExit codeStderr
Element not found1error: JS exception: Uncaught
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Clear a search input:

hubcap clear '#search'

Clear an input, then type new text:

hubcap clear '#email' && hubcap focus '#email' && hubcap type 'new@example.com'

See also

  • fill - Focus, clear, and type in one step
  • setvalue - Set the value directly
  • focus - Focus an element