Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gem/lib/capybara-select2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ def select2(value, options = {})
raise "Must pass a hash containing 'from' or 'xpath' or 'css'" unless options.is_a?(Hash) and [:from, :xpath, :css].any? { |k| options.has_key? k }

if options.has_key? :xpath
select2_container = find(:xpath, options[:xpath])
select2_container = find(:xpath, options[:xpath], match: :first)
elsif options.has_key? :css
select2_container = find(:css, options[:css])
select2_container = find(:css, options[:css], match: :first)
else
select_name = options[:from]
select2_container = find("label", text: select_name).find(:xpath, '..').find(".select2-container")
select2_container = find("label", text: select_name, match: :first).find(:xpath, '..').find(".select2-container")
end

# Open select2 field
Expand Down