Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Send keypress events when setting text for inputs #44

Closed
wants to merge 1 commit into from
Closed

Send keypress events when setting text for inputs #44

wants to merge 1 commit into from

Conversation

j16r
Copy link
Contributor

@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
Copy link

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
Copy link
Contributor Author

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
Copy link
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants