Testing jQuery Autocomplete using Capybara

This is a brilliant tip. I would never have worked this out on my own. Thank you Jack Russell Software Company.


The sleep commands were the critical bit, without them Selenium just wasn't firing the JavaScript event handlers.

Here are the relevant lines from my integration test.
# We are looking for "Make Two"    
s.fill_in "Make", :with => "Make"
sleep 1
page.execute_script("$('.ui-menu-item a:contains(\"Make Two\")').trigger('mouseenter').click();")