Cucumber and Capybara, clicking a non-link or button element

You can click on an element via I add the following for this in my web_steps.rb to click on divs.

When /^(?:|I )click within "([^"]*)"$/ do |selector|

There is also Element.trigger('mouseover') which appears to enable hover albeit not working with Selenium.

It is also very likely you will need to decorate your feature/scenario with Capybara’s provided @javascript tag.

Leave a Comment