Skip to content

Instantly share code, notes, and snippets.

@hugomaiavieira
Created January 8, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugomaiavieira/a6f581d4e38984bf2b07 to your computer and use it in GitHub Desktop.
Save hugomaiavieira/a6f581d4e38984bf2b07 to your computer and use it in GitHub Desktop.
Select2Capybara
module Select2Capybara
def select2(selector, value)
# on recent versions of select2, the .select2-focusser was replaced by
# .select2-input
execute_script("$('#{selector} .select2-focusser').val('#{value}')")
execute_script("$('#{selector} .select2-container').select2('open')")
wait_for_ajax
find('.select2-results li:first-child').click
end
end
RSpec.configure do |config|
config.include Select2Capybara
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment