lib/appium_lib/android/helper.rb in appium_lib-9.5.0 vs lib/appium_lib/android/helper.rb in appium_lib-9.6.0

- old
+ new

@@ -21,22 +21,22 @@ @result = '' @keys = %w(text resource-id content-desc) end # http://nokogiri.org/Nokogiri/XML/SAX/Document.html - def start_element(name, attrs = []) + def start_element(name, attrs = [], driver = $driver) return if filter && !name.downcase.include?(filter) attributes = {} attrs.each do |key, value| attributes[key] = value if keys.include?(key) && !value.empty? end # scoped to: text resource-id content-desc attributes_values = attributes.values - strings = $driver.lazy_load_strings + strings = driver.lazy_load_strings id_matches = strings.empty? ? [] : strings.select { |_key, value| attributes_values.include? value } string_ids = nil if id_matches && !id_matches.empty? @@ -283,17 +283,11 @@ # Find the first element that contains value # @param class_name [String] the class name for the element # @param value [String] the value to search for # @return [Element] def complex_find_contains(class_name, value) - if automation_name_is_uiautomator2? - elements = find_elements :uiautomator, string_visible_contains(class_name, value) - raise _no_such_element if elements.empty? - elements.first - else - find_element :uiautomator, string_visible_contains(class_name, value) - end + find_element :uiautomator, string_visible_contains(class_name, value) end # Find all elements containing value # @param class_name [String] the class name for the element # @param value [String] the value to search for @@ -341,16 +335,10 @@ # Find the first element exactly matching value # @param class_name [String] the class name for the element # @param value [String] the value to search for # @return [Element] def complex_find_exact(class_name, value) - if automation_name_is_uiautomator2? - elements = find_elements :uiautomator, string_visible_exact(class_name, value) - raise _no_such_element if elements.empty? - elements.first - else - find_element :uiautomator, string_visible_exact(class_name, value) - end + find_element :uiautomator, string_visible_exact(class_name, value) end # Find all elements exactly matching value # @param class_name [String] the class name for the element # @param value [String] the value to search for