lib/appium_lib/ios/element/generic.rb in appium_lib-0.5.5 vs lib/appium_lib/ios/element/generic.rb in appium_lib-0.5.6
- old
+ new
@@ -61,16 +61,16 @@
def find text
ele = nil
# prefer value search. this may error with:
# Can't use in/contains operator with collection 1
js = first_ele_js "value contains[c] '#{text}'"
- ignore { ele = execute_script js }
+ ele = ignore { execute_script js }
# now search name and label if the value search didn't match.
unless ele
js = first_ele_js "name contains[c] '#{text}' || label contains[c] '#{text}'"
- ignore { ele ||= execute_script js }
+ ele = ignore { execute_script js }
end
# manually raise error if no element was found
raise Selenium::WebDriver::Error::NoSuchElementError, 'An element could not be located on the page using the given search parameters.' unless ele
@@ -79,13 +79,17 @@
# Return all elements matching text.
# @param text [String] the text to search for
# @return [Array<Element>] all matching elements
def finds text
- # returnElems requires a wrapped $(element).
- # must call toArray when using withPredicate instead of firstWithPredicate.
- js = all_ele_js "name contains[c] '#{text}' || label contains[c] '#{text}' || value contains[c] '#{text}'"
- execute_script js
+ eles = []
+ # value contains may error
+ js = all_ele_js "value contains[c] '#{text}'"
+ eles = ignore { execute_script js }
+
+ js = all_ele_js "name contains[c] '#{text}' || label contains[c] '#{text}'"
+ eles += ignore { execute_script js }
+ eles
end
# Return the first element matching text.
# @param text [String] the text to search for
# @return [Element] the first matching element
\ No newline at end of file