Skip to content

feat(node): support clear: in set and warn about unsupported options - #378

Merged
route merged 2 commits into
mainfrom
feat/set-clear
Nov 25, 2026
Merged

route merged 2 commits into
mainfrom
feat/set-clear

Conversation

@route

@route route commented Nov 25, 2026

Copy link
Copy Markdown
Member

Part of #307. Follows #377, which made text fields use real key presses.

clear: works like Capybara's Selenium node, for text inputs and textareas:

clear: Before typing rapid: applies
nil (default) select the value so typing replaces it yes
:none caret to the end, keep the value yes
:backspace caret to the end, one Backspace per existing character no
Array of keys caret to the end, press the keys no
anything else raises ArgumentError

Differences from Selenium:

  • Textareas move the caret with setSelectionRange, because End only reaches the end of the current line. Inputs press End, since type="email" doesn't support setSelectionRange.
  • An empty value with :none, :backspace or an Array runs only the clearing step.
  • An unknown clear: value raises instead of acting like nil.

#377 dropped the warning for options Cuprite ignores. It's back for any option other than rapid: and clear:, naming them. Those two stay silent on fields that don't use them, so Capybara.default_set_options = { clear: :backspace } doesn't warn on every checkbox.

  • The typing code moves into Node::Typing first (ref commit, no behavior change), which also brings Node back under 300 lines.
  • 8 new specs under Node#set. 7 fail without the feature; the checkbox no-warning one passes both ways.
  • YARD on Node#set and a CHANGELOG line under Added.

clear: works like Selenium's: :none appends, :backspace deletes the value with Backspace, an Array of keys is pressed before typing, and
an unknown value raises ArgumentError. The caret moves to the end with End in inputs and setSelectionRange in textareas, where End only
reaches the end of the line. Options other than rapid: and clear: warn again, as before real key presses; those two stay silent on
fields that don't use them, so default_set_options doesn't warn on every checkbox.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant