Capybara硒司机,盘旋元素

nzi*_*nab 4 selenium rspec cucumber capybara ruby-on-rails-3

我正在测试的应用程序最初隐藏了一些元素.当鼠标悬停在单独的元素上时,它们将通过CSS显示:

.thread_options{
  display: none;
}
.btn_thread_options:hover .thread_options{
  display: inline;
}
Run Code Online (Sandbox Code Playgroud)

当您将鼠标悬停在.btn_thread_options元素上时,会显示一些我希望Capybara单击的链接.尝试单击这些而不做任何使用click_link "Send Response"会给我错误:

Failure/Error: click_link("Send Response")
Selenium::WebDriver::Error::ElementNotVisibleError:
  Element is not currently visible and so may not be interacted with
Run Code Online (Sandbox Code Playgroud)

尝试使用其他方式点击它

page.execute_script("$('.btn_thread_options').trigger('mouseover')")
Run Code Online (Sandbox Code Playgroud)

也不起作用(相同的结果).

也不是先点击该项目以试图强制它被鼠标悬停:

page.find(".btn_thread_options").click
Run Code Online (Sandbox Code Playgroud)

有没有办法让这个正常工作?

mik*_*son 6

这已被添加到Capybara:

find(:css, "#menu").hover
Run Code Online (Sandbox Code Playgroud)