Skip to content

Instantly share code, notes, and snippets.

@h-lame
Created July 19, 2010 14:13
Show Gist options
  • Save h-lame/481451 to your computer and use it in GitHub Desktop.
Save h-lame/481451 to your computer and use it in GitHub Desktop.
module Capybara::Driver
class Envjs
PreTypingEvents = ['focus']
TypingEvents = ['keydown', 'keypress', 'keyup']
PostTypingEvents = ['change', 'blur']
def self.type_into(field, value)
PreTypingEvents.each { |e| field.trigger(e) }
field.set(value)
TypingEvents.each { |e| field.trigger(e) }
PostTypingEvents.each { |e| field.trigger(e) }
end
end
end
When /^(?:|I )type "([^\"]*)" into "([^\"]*)"(?: within "([^\"]*)")?$/ do |value, field, selector|
with_scope(selector) do
input_elem = find_field(field)
Capybara::Driver::Envjs.type_into(input_elem, value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment