Repository navigation
fix(node): focus instead of clicking an element send_keys types into - #386
Merged
Merged
Conversation
send_keys clicked an element that didn't have focus, so a checkbox toggled before a space toggled it back, a link was followed, and the keys went where the click put the caret, the middle of a filled field. It now focuses the element and puts the caret at the end, pressing End for email and number inputs, which have no selection API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node#send_keysclicked an element that didn't have focus before typing. This dates back to the initial commit. Three things went wrong:checkbox.send_keys(:space)left the checkbox unchecked: the click checked it and the space unchecked it.onclick, or followed it..comsent touser@examplegaveuser@exam.comple. The existing specs only used short values like "Text", so this never showed up.What it does now, matching WebDriver:
_cuprite.focusForTypingis one JS call. It does nothing if the element already has focus or contains the selection, as before. Otherwise it callsfocus()and puts the caret at the end: a collapsed range for contenteditable,setSelectionRangefor inputs and textareas that support it.trueand Ruby presses End.set(clear: :none)does the same since feat(node): support clear: in set and warn about unsupported options #378.Specs: three new ones under
Node#send_keys(checkbox, link, filled email input). All three fail without the fix.node_specanddriver_specpass (305 examples), and so do the related Capybara specs (send_keys,fill_in,:focused). CHANGELOG line under Fixed.