水豚找不到语义用户界面的选择框 [英] Capybara can't find select box for Semantic-ui

查看:93
本文介绍了水豚找不到语义用户界面的选择框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 capybara capybara-webkit Semantic-ui 结合使用,但是它似乎无法使用下拉菜单,因为< select> 元素被隐藏:

I use capybara with capybara-webkit and Semantic-ui, but it seams that dropdowns doesn't work out of box, because <select> element is hidden:

# feature_spec.rb
select 'option1', from: 'Options'

$ rspec feature_spec.rb

Capybara::ElementNotFound:
  Unable to find select box "Options"

您对此有可行的解决方案吗?

Do you have working solutions for this?

推荐答案

我创建了此帮助程序:

# for Semantic-ui dropdown
def select_from_dropdown(item_text, options)
  # find dropdown selector
  dropdown = find_field(options[:from], visible: false).first(:xpath,".//..")
  # click on dropdown
  dropdown.click
  # click on menu item
  dropdown.find(".menu .item", :text => item_text).click
end

# in spec
select_from_dropdown 'option1', from: 'Options'

我希望它会有所帮助:-)

I hope it helps :-)

这篇关于水豚找不到语义用户界面的选择框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆