class Appium::Android::AndroidElements
def filter=(value)
def filter=(value) # nil and false disable the filter return @filter = false unless value # rubocop:disable Lint/ReturnInVoidContext @filter = value.to_s.downcase end
def initialize # rubocop:disable Lint/MissingSuper
def initialize # rubocop:disable Lint/MissingSuper reset @filter = false end
def reset
def reset @result = '' @keys = %w(text resource-id content-desc) end
def start_element(name, attrs = [], driver = $driver)
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 id_matches = strings.empty? ? [] : strings.select { |_key, value| attributes_values.include? value } string_ids = nil if id_matches && !id_matches.empty? space_suffix = ' ' * 15 # 15 is ' strings.xml: '.length string_ids = '' # add first string_ids += "#{id_matches.shift[0]}\n" # use padding for remaining values # [0] = key, [1] = value id_matches.each do |match| string_ids += "#{space_suffix}#{match[0]}\n" end end string = '' text = attributes['text'] desc = attributes['content-desc'] id = attributes['resource-id'] if !text.nil? && text == desc string += " text, desc: #{text}\n" else string += " text: #{text}\n" unless text.nil? string += " desc: #{desc}\n" unless desc.nil? end string += " id: #{id}\n" unless id.nil? string += " strings.xml: #{string_ids}" unless string_ids.nil? @result += "\n#{name}\n#{string}" unless attributes.empty? end