7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/capybara_select2/helpers.rb', line 7
def select2(*args)
options = args.pop
values = args
Utils.validate_options!(options)
select2_container = Utils.find_select2_container(options, page)
select2_version = Utils.detect_select2_version(select2_container)
opener_selector = Selectors.opener_selector(select2_version)
option_selector = Selectors.option_selector(select2_version)
values.each do |value|
select2_container.find(:css, opener_selector).click
if options[:search] || options[:tag]
search_input_selector = Selectors.search_input_selector(select2_version)
find(:xpath, '//body').find(:css, search_input_selector).set value
end
find_options = { text: value }
find_options[:match] = options[:match] if options[:match]
find_options[:exact_text] = options[:exact_text] if options[:exact_text]
find(:xpath, '//body').find(:css, option_selector, find_options).click
end
end
|