I'm using similar construction:
<div class="edit" style="visibility: hidden;">
<a href="some_path" id="edit_item">Edit</a>
</div>
Then I hover mouse this element become visible, but I have difficult to interact this actions with tests(using cucumber, capybara, selenium).
I get an error
Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
I tried to use Element.trigger(event) with mouseover, but it doesn't work in selenium... How I can interact with this element?
I solved this problem using execute_script from capybara:
When /^I hover element "([^""]*)"(?: within "([^""]*)")?$/ do |id,selector|
with_scope(selector) do
page.execute_script("$('#{id}').mouseover();")
end
end
When /^I click in hide element "([^""]*)"(?: within "([^""]*)")?$/ do |id,selector|
with_scope(selector) do
page.execute_script("$('#{id}').click();")
end
end
but this solution doesn't work with css - display: none;
Be aware that
with_scope
has no effect onexecute_script
.