hubcap setvalue

Set an input element’s value directly without simulating keystrokes.

When to use

Use setvalue to programmatically assign a value to an input element, bypassing individual keystroke events. This is useful for sliders, date pickers, hidden inputs, and other elements where simulated typing is unnecessary or impractical. Use fill for realistic user input simulation that fires keystroke events.

Usage

hubcap setvalue <selector> <value>

Arguments

ArgumentTypeRequiredDescription
selectorstringYesCSS selector of the input element
valuestringYesValue to set on the element

Flags

None.

Output

FieldTypeDescription
selectorstringThe selector of the element
valuestringThe value that was set
{"selector":"#slider","value":"75"}

Errors

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

Examples

Set a range slider value:

hubcap setvalue '#slider' '75'

Set a hidden input value:

hubcap setvalue '[name="token"]' 'abc123'

Set a date input:

hubcap setvalue '#date' '2025-01-15'

Set a value then dispatch a change event to trigger listeners:

hubcap setvalue '#config' 'dark' && hubcap dispatch '#config' change

See also

  • fill - Fill an input by typing with keystroke events
  • value - Get the current value of an input
  • clear - Clear an input value