Riddler Riddler - 2 years ago 201
AngularJS Question

Angular material select for capybara

Can I make select in RoR RSpec + Capybara?
Usually i use:

select 'something', from: 'select_name'

But for angular's
is doesn't work.
Capybara show error:

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

Answer Source

I simple add a custom md_select method to Capybara.

def md_select name, from: ''
  puts 'md_select `from:` param is required. For example `md_select select_value, from: select_name`' if from.blank?

  find(:xpath, "//md-select[@name='#{from}']").click
  find(:xpath, "//md-select-menu/md-content/md-option/div[text()='#{name}']").click

And now we can use it in RSpec:

md_select select_value, from: 'select_name'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download