1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Added unselect for celerity driver

This commit is contained in:
Carl Porth 2010-02-19 18:13:23 -08:00
parent ee041e575d
commit dd892846e3

View file

@ -26,6 +26,23 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
def unselect(option)
unless node.multiple?
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
end
# FIXME: couldn't find a clean way to unselect, so clear and reselect
selected_options = node.selected_options
if unselect_option = selected_options.detect { |value| value == option } ||
selected_options.detect { |value| value.index(option) }
node.clear
(selected_options - [unselect_option]).each { |value| node.select_value(value) }
else
options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
end
def click
node.click
end