lib/watir/elements/select.rb in watir-6.8.4 vs lib/watir/elements/select.rb in watir-6.9.0

- old
+ new

@@ -39,45 +39,49 @@ # @param [String, Regexp] str_or_rx # @raise [Watir::Exception::NoValueFoundException] if the value does not exist. # @return [String] The text of the option selected. If multiple options match, returns the first match. # - def select(str_or_rx) - select_by str_or_rx + def select(*str_or_rx) + results = str_or_rx.flatten.map { |v| select_by v} + results.first end # # Select all options whose text or label matches the given string. # # @param [String, Regexp] str_or_rx # @raise [Watir::Exception::NoValueFoundException] if the value does not exist. # @return [String] The text of the first option selected. # - def select_all(str_or_rx) - select_all_by str_or_rx + def select_all(*str_or_rx) + results = str_or_rx.flatten.map { |v| select_all_by v } + results.first end # # Uses JavaScript to select the option whose text matches the given string. # # @param [String, Regexp] str_or_rx # @raise [Watir::Exception::NoValueFoundException] if the value does not exist. # - def select!(str_or_rx) - select_by!(str_or_rx, :single) + def select!(*str_or_rx) + results = str_or_rx.flatten.map { |v| select_by!(v, :single) } + results.first end # # Uses JavaScript to select all options whose text matches the given string. # # @param [String, Regexp] str_or_rx # @raise [Watir::Exception::NoValueFoundException] if the value does not exist. # - def select_all!(str_or_rx) - select_by!(str_or_rx, :multiple) + def select_all!(*str_or_rx) + results = str_or_rx.flatten.map { |v| select_by!(v, :multiple) } + results.first end # # Selects the option(s) whose value attribute matches the given string. #