我用的是类似的结构:
<div class="edit" style="visibility: hidden;">
<a href="some_path" id="edit_item">Edit</a>
</div>然后我悬停鼠标这个元素变得可见,但是我很难与测试交互这个动作(使用黄瓜,水豚,硒)。
我犯了个错误
元素当前不可见,因此可能无法与(Selenium::WebDriver::Error::ElementNotDisplayedError)交互。
我试着在鼠标上使用Element.trigger(事件),但是它在selenium中不起作用.我如何才能与这个元素互动?
发布于 2011-10-17 19:04:08
我用capybara的execute_script解决了这个问题:
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但是这个解决方案不适用于css - display: none;
https://stackoverflow.com/questions/7784849
复制相似问题