class Appium::Common::CountElements

def formatted_result

def formatted_result
  @result
    .sort_by { |_element, count| count }
    .reverse
    .reduce('') { |acc, element| "#{acc}#{element[1]}x #{element[0]}\n" }
    .strip
end

def initialize(platform) # rubocop:disable Lint/MissingSuper

rubocop:disable Lint/MissingSuper
def initialize(platform) # rubocop:disable Lint/MissingSuper
  reset
  @platform = platform
end

def reset

def reset
  @result = Hash.new 0
end

def start_element(name, attrs = [])

http://nokogiri.org/Nokogiri/XML/SAX/Document.html
def start_element(name, attrs = [])
  element_visible = case @platform.to_sym
                    when :android
                      true
                    else # :ios, :windows
                      Hash[attrs]['visible'] == 'true'
                    end
  @result[name] += 1 if element_visible
end