This answer worked for me Capybara: Select an option by value not text by @d_rail
You create a helper first. I put this helper in spec/support/utilities.rb
def select_by_value(id, value)
option_xpath = "//*[@id='#{id}']/option[@value='#{value}']"
option = find(:xpath, option_xpath).text
select(option, :from => id)
end
Then to use it:
select_by_value "select_id", "select_option"
In my case, the select tag has the id user_category
and the option I wanted to select was Musician
. So my example was
select_by_value "user_category", "Musician"