Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Node#Send keys to standardize usage across drivers #1472

Merged
merged 2 commits into from
Feb 26, 2015
Merged

Conversation

twalpole
Copy link
Member

Implementation of item discussed in Issue #1459 - @jferris @jonleighton @mhoran Thoughts on implementing this in your drivers for Capybara 2.5 ?

# element.send_keys [:control, 'a'], :space #=> value: ' '
#
# Symbols supported for keys
# :null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing space

@mhoran
Copy link
Contributor

mhoran commented Jan 26, 2015

There are a few keys that we can't send in capybara-webkit

:left_shift
:left_control
:left_alt
:arrow_left
:arrow_up
:arrow_right
:arrow_down
:separator
:decimal
:command

There is no differentiation between shift and left shift, control and left control, or alt and left alt in Qt. We only have left, up, right, and down mappings, but nothing corresponding to "arrow".

Is :separator |? Is :decimal .?

Command is not a cross-platform key, so it is not supported by Qt. On OS X, Qt::Key_Control maps to command, and Qt::Key_Meta maps to control. We could conceivably map these as appropriate on each individual platform, but that may be surprising for users.

Finally, what should :null send?

@twalpole
Copy link
Member Author

@mhoran - The list of symbols is what selenium understands
:left_shift, :left_alt, :left_control are just aliases for :shift, :alt, 🛂
:arrow_up, :arrow_down, :arrow_right, :arrow_left are aliases for :up, :down, :right, :left.
:command is an alias for :meta.
:decimal is the numeric keypad .
:add, :divide, :subtract, :multiply are the numeric keypad instances of +, /, -, *

:separator is the numeric keypad "seperator" key (different from the :decimal key) - the keycode is 108 and I'm guessing its a key returned by non-english keyboards although I can't find info that specifically states that.

:null - appears to be used in lower level key routines in selenium to trigger release of all modifier keys. It is probably not needed for this so I'm removing it from the list

@twalpole twalpole closed this Jan 26, 2015
@twalpole twalpole reopened this Jan 26, 2015
@jferris
Copy link

jferris commented Jan 28, 2015

There is no differentiation between shift and left shift, control and left control, or alt and left alt in Qt. We only have left, up, right, and down mappings, but nothing corresponding to "arrow".

I'm guessing that if we just sent shift, control, and alt, that would be least surprising to users. Same goes for up/arrow_up.

@twalpole
Copy link
Member Author

@jferris I have removed the arrow_x and left_x aliases from the list of required supported key symbols - For future info DOM Level 3 does support identifying left vs right instances of shift, alt, control via the location attribute of a KeyboardEvent however not all browsers support it at the moment https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.location and selenium doesn't currently provide a way to set it, so we may have to revisit left_shift, right_shift, etc in the future

twalpole added a commit that referenced this pull request Feb 26, 2015
Add Capybara::Node::Element#send_keys to standardize usage across drivers, and support in selenium driver
@twalpole twalpole merged commit 50a9a8c into master Feb 26, 2015
@twalpole twalpole deleted the send_keys branch August 26, 2015 06:05
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.

4 participants