Has anyone figured out how to trigger a hoverIntent event via Capybara?
In my Rails app's main view, edit buttons appear in a table cell when the user hovers the mouse over that cell.
I recently added the jQuery hoverIntent plug-in to delay the appearance of these buttons, so that the UI doesn't look like a busy switchboard when the user moves the mouse quickly across the page.
The addition of hoverIntent broke several Cucumber-Capybara-Selenium tests, unfortunately. The tests had been making the buttons appear with a step like this (simplified):
And /^I hover on the table cell with ID "(.*)"$/ do |cell_id|
selector = "td#" + cell_id
js = %Q{ (function() { jQuery("#{ selector }").mouseover(); })() }
page.evaluate_script js
end
This worked well for the regular mouseover event, but it doesn't trigger hoverIntent.
One (kind-of-hackish) solution would be to create named functions to pass to hoverIntent for the mouseover and mouseout behaviors (instead of anonymous, inline functions as I'm doing now). The Capybara step could then invoke the mouseover function by name, and get the same result.
This would side-step the testing of the hoverIntent functionality, though, so it isn't optimal.
Thanks in advance for any suggestions.