Created
July 1, 2013 13:46
-
-
Save pyykkis/5900919 to your computer and use it in GitHub Desktop.
Select2 helper for capybara-webkit
This file contains hidden or 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
module Helpers | |
def select2(scope, opts) | |
scope.find('.select2-choice').click | |
if opts.has_key? :type_in | |
input = find '.select2-drop-active:not(.select2-offscreen) .select2-search .select2-input' | |
input.set opts[:type_in] | |
input.trigger('keyup-change') | |
end | |
sleep 2 | |
all(".select2-drop-active:not(.select2-offscreen) .select2-result") | |
.select { |e| /#{opts[:then_select]}/ =~ e.text } | |
.first | |
.click | |
end | |
end |
dmons
commented
Sep 17, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment