Riddler Riddler - 3 months ago 56
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"


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'