3
4
5
6
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
33
34
35
36
37
|
# File 'lib/capybara_select2/helpers.rb', line 3
def select2(value, options = {})
open_select = "" +
".select2-choice, .select2-search-field," + ".select2-selection"
search_input = "" +
".select2-dropdown-open input.select2-focused," + ".select2-drop-active input.select2-input," + ".select2-container--focus input.select2-search__field," + ".select2-container--open input.select2-search__field"
option = "" +
".select2-container-active .select2-result," + ".select2-drop-active .select2-result," + ".select2-results .select2-results__option"
container = if options[:xpath]
find(:xpath, options[:xpath])
elsif options[:css]
find(:css, options[:css])
else
find("label:not(.select2-offscreen)", text: options[:from])
.find(:xpath, '..')
.find('.select2-container')
end
container.find(open_select).click
if options[:search] || options[:tag]
find(search_input).set value
end
find(option, text: value).click
end
|