lib/watir-classic/input_elements.rb in watir-classic-3.1.0 vs lib/watir-classic/input_elements.rb in watir-classic-3.2.0.rc1

- old
+ new

@@ -23,11 +23,11 @@ attr_ole :multiple? # This method clears the selected items in the select box def clear perform_action do - options.each {|option| option.clear} + options.each(&:clear) end end # This method selects an item, or items in a select box, by text. # Raises NoValueFoundException if the specified value is not found. @@ -92,27 +92,19 @@ attr_ole :value attr_ole :label def select perform_action do - unless selected? - ole_object.selected = true - select_list.dispatch_event("onChange") - @container.wait - end + change_selected true unless selected? end end def clear raise TypeError, "you can only clear multi-selects" unless select_list.multiple? perform_action do - if selected? - ole_object.selected = false - select_list.dispatch_event("onChange") - @container.wait - end + change_selected false if selected? end end def selected? assert_exists @@ -131,9 +123,16 @@ el = parent el = el.parent until el.is_a?(SelectList) raise "SELECT element was not found for #{self}!" unless el @select_list = el + end + + def change_selected(value) + select_list.focus + ole_object.selected = value + select_list.dispatch_event("onChange") + @container.wait end end # # Input: Button