public
Created

  • Download Gist
helpers.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.