Skip to content

Instantly share code, notes, and snippets.

@cj
Created March 8, 2012 21:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cj/2003631 to your computer and use it in GitHub Desktop.
Save cj/2003631 to your computer and use it in GitHub Desktop.
# I created this because the headless webkit doesn't handle click/mouse events very well
# so when using jquery events/binds like click/focus/mousedown etc... the tests weren't passing
# because the javascript wasn't being executed because no mosue event was triggered
# this gets around that and works just like fill_in
def jquery_fill_in(selector, options)
page.execute_script %Q{
$('body').focus;
if((selector = $('##{selector}')).length || ($selector = $('label:contains(#{selector})').parent().find(':input')).length) {
$selector.focus().click().val('#{options[:with]}').keydown();
} else {
throw 'Selector (#{selector}) not found';
}
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment