capybara: fill_in "field_id", with => "" does not trigger keyUp event
I am using jQuery to bind a text field to the keyUp event. A fill_in "field_id", with => "test" works as expected (keyUp is triggered), but clearing the field with fill_in "field_id", with => "" does not trigger that event.
About this issue
- Original URL
- State: closed
- Created 14 years ago
- Comments: 21 (5 by maintainers)
@DougMaisells send_keys needs to be called on an element - you probably want something like
of you could just do something like
find_field(‘Prefix’).send_keys([:control, “a”], :backspace)
which should have a similar effect (assuming ctrl-a selects all contents in the platform you’re testing on).
To work around this I use fill_in to clear the input field, and then manually trigger a keyup event on the field. I am using capybara via cucumber, so the below is the helper method I use for triggering events, and the cucumber step that I use when I need to clear a field: