hubcap fill

Clear an input and type new text in one step.

When to use

Use fill to replace the contents of an input field with new text, simulating realistic user input with keystrokes. Use type to append text without clearing first. Use setvalue to set the value directly without firing individual keystroke events.

Usage

hubcap fill <selector> <text>

Arguments

ArgumentTypeRequiredDescription
selectorstringYesCSS selector of the input element
textstringYesText to fill into the input

Flags

None.

Output

FieldTypeDescription
filledbooleanWhether the fill succeeded
selectorstringThe selector that was filled
textstringThe text that was entered
{"filled":true,"selector":"#email","text":"user@example.com"}

Errors

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

Examples

Fill an email input:

hubcap fill '#email' 'user@example.com'

Fill a search box:

hubcap fill '[name="q"]' 'hubcap CLI'

Fill a login form and submit it:

hubcap fill '#email' 'user@example.com' && hubcap fill '#password' 'secret' && hubcap click '#submit'

See also

  • clear - Clear an input field
  • type - Type text keystroke by keystroke without clearing
  • setvalue - Set a value directly without typing
  • focus - Focus an element
  • value - Get the current value of an input