lib/watir/elements/select.rb in watir-6.0.0.beta5 vs lib/watir/elements/select.rb in watir-6.0.0
- old
+ new
@@ -5,12 +5,10 @@
#
# Clears all selected options.
#
def clear
- assert_exists
-
raise Error, "you can only clear multi-selects" unless multiple?
options.each do |o|
click_option(o) if o.selected?
end
@@ -21,11 +19,11 @@
#
# @return [Watir::OptionCollection]
#
def options
- assert_exists
+ wait_for_exists
super
end
#
# Returns true if the select list has one or more options where text or label matches the given value.
@@ -33,12 +31,10 @@
# @param [String, Regexp] str_or_rx
# @return [Boolean]
#
def include?(str_or_rx)
- assert_exists
-
element_call do
@element.find_elements(:tag_name, 'option').any? do |e|
str_or_rx === e.text || str_or_rx === e.attribute(:label)
end
end
@@ -78,12 +74,10 @@
# @raise [Watir::Exception::UnknownObjectException] if the options do not exist
# @return [Boolean]
#
def selected?(str_or_rx)
- assert_exists
-
match_found = false
element_call do
@element.find_elements(:tag_name, 'option').each do |e|
matched = str_or_rx === e.text || str_or_rx === e.attribute(:label)
@@ -123,12 +117,10 @@
end
private
def select_by(how, str_or_rx)
- assert_exists
-
case str_or_rx
when String, Numeric
select_by_string(how, str_or_rx.to_s)
when Regexp
select_by_regexp(how, str_or_rx)
@@ -218,10 +210,9 @@
def safe_text(element)
element.text
rescue Selenium::WebDriver::Error::StaleElementReferenceError, Selenium::WebDriver::Error::UnhandledAlertError
# guard for scenario where selecting the element changes the page, making our element obsolete
-
''
end
def no_value_found(arg, msg = nil)
raise NoValueFoundException, msg || "#{arg.inspect} not found in select list"