Send keypress events when setting text for inputs #44

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@j16r
j16r commented May 4, 2011

When setting the text of input types of 'text', 'textarea' and 'password' the capybara webkit driver does not send any keypress events, which are important for some of the widgets we're using.

This patch sends a keydown, keypress and keyup event for every character added to the input and builds the value progressively so it should act more closely to how a real user interacts with a text box.

@Fonsan
Fonsan commented May 4, 2011

I'm not sure this is the way a normal browser would behave and if your really intended to simulate a user typing, then triggering a sequence of keypresses might be the right way to go

@j16r
j16r commented May 4, 2011

I've emulated the same behaviour I saw when interacting with a text input using google chrome, though it may be a little off in some regards (keycode?) it sends the events in the same order, at least the ones I created a listener for.

There doesn't appear to be any way of sending keypress events in capybara to emulate this behaviour.

@jferris
Member
jferris commented May 25, 2011

Thanks for the patch. I merged this in. If anybody discovers discrepancies between how this behaves and how a real browser session behaves, feel free to report them. These user interactions are tricky, because there's more than one way to fill in a text input (type, paste, click in, tab in, etc). This series of events seems realistic to me.

@jferris jferris closed this May 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment