Has anyone figured out how to raise a hoverIntent event via Capybara?
In the main window of the Rails application, the edit buttons are displayed in a table cell when the user hovers over this cell.
I recently added a jQuery hoverIntent plugin to delay the appearance of these buttons so that the user interface does not look like a busy switch when the user quickly moves the mouse around the page.
The addition of hoverIntent unfortunately led to several tests of the Cucumber-Capybara-Selenium. Tests made buttons with this step (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 works well for a regular mouseover event, but it does not call hoverIntent.
One solution (like a hacker one) would be to create named functions to go to hoverIntent for mouse and mouse behavior (instead of the anonymous built-in functions that I'm doing now). The Capybara step can then call the mouse function by name and get the same result.
It will be a step-by-step test of the functionality of hoverIntent, however, this is not optimal.
Thanks in advance for any suggestions.
source share