加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – Capybara selenium驱动程序,悬停元素

发布时间:2020-12-17 03:53:31 所属栏目:百科 来源:网络整理
导读:我正在测试的应用程序最初隐藏了一些元素.当鼠标悬停在单独的元素上时,它们将通过CSS显示: .thread_options{ display: none;}.btn_thread_options:hover .thread_options{ display: inline;} 当您将鼠标悬停在.btn_thread_options元素上时,会显示一些我希望
我正在测试的应用程序最初隐藏了一些元素.当鼠标悬停在单独的元素上时,它们将通过CSS显示:

.thread_options{
  display: none;
}
.btn_thread_options:hover .thread_options{
  display: inline;
}

当您将鼠标悬停在.btn_thread_options元素上时,会显示一些我希望Capybara单击的链接.使用click_link“发送响应”尝试单击这些而不执行任何操作会给出错误:

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

尝试使用其他方式点击它

page.execute_script("$('.btn_thread_options').trigger('mouSEOver')")

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

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

page.find(".btn_thread_options").click

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

解决方法

这是 added到Capybara:

find(:css,"#menu").hover

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读