Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hover mouse on capybara

I have a button on a page which only appears when hovering over a certain element. But I can't figure out how to emulate this and then click on the link so I can cucumber test it using Capybara and Selenium.

like image 646
yehud Avatar asked Aug 14 '11 09:08

yehud


1 Answers

You may want use a custom defined step for this, like:

When /^I click "([^"]*)" inside element "([^"]*)"$/ do |button, element_name| 

Inside, you write something like:

begin
  evaluate_script("$('#{element_name}').trigger('mouseover')")
  rescue Capybara::NotSupportedByDriverError
end

And then you click that button you want :)

like image 127
socjopata Avatar answered Oct 24 '22 05:10

socjopata