Skip to content

Instantly share code, notes, and snippets.

@patreeceeo
Forked from sirbrillig/select2_helper.rb
Last active August 29, 2015 14:05
Show Gist options
  • Save patreeceeo/af4a06db090a81665893 to your computer and use it in GitHub Desktop.
Save patreeceeo/af4a06db090a81665893 to your computer and use it in GitHub Desktop.
Helper for filling in select inputs wrapped by select2.js using Rspec + Capybara
def fill_in_select2(selector, options={})
page.find(:css, "#s2id_#{selector} a").click
page.find(:css, "#select2-drop .select2-search input.select2-input").set options[:with]
page.find(:css, "#select2-drop .select2-result-label").click # Choose the first result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment