Created
October 2, 2014 11:49
-
-
Save hsuh/8405170e27f1130ce107 to your computer and use it in GitHub Desktop.
capybara select by value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_by_value(id, value) | |
option_xpath = "//*[@id='#{id}']/option[@value='#{value}']" | |
option = find(:xpath, option_xpath).text | |
select(option, :from => id) | |
end | |
Save in a .rb file in spec/support/ (Optional) | |
Example use: | |
before do | |
select_by_value 'some_field_id', 'value' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment