bob*_*lin 4 ruby-on-rails capybara capybara-webkit semantic-ui
我将capybara与capybara-webkit和Semantic-ui结合使用,但它似乎无法显示下拉菜单,因为<select>element是隐藏的:
# feature_spec.rb
select 'option1', from: 'Options'
$ rspec feature_spec.rb
Capybara::ElementNotFound:
Unable to find select box "Options"
Run Code Online (Sandbox Code Playgroud)
您对此有可行的解决方案吗?
我创建了这个帮助器:
# 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'
Run Code Online (Sandbox Code Playgroud)
希望对您有所帮助:-)
| 归档时间: |
|
| 查看次数: |
581 次 |
| 最近记录: |