40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/selenium/webdriver/elements/select.rb', line 40
def select_by_text selection
if selection.is_a?(Array)
unless @element['multiple']
raise "Attempt to select multiple values in a listbox with single selection mode"
end
options = @element.find_elements :tag_name => 'option'
options.each do |opt|
if (selection.include? opt.text)
opt.select unless opt.selected?
else
opt.toggle if opt.selected?
end
end
else
options = @element.find_elements :tag_name => 'option'
options.each do |opt|
if (opt.text == selection)
opt.select
break
end
end
end
end
|