class Appium::Common::CountElements

@private nokogiri.org/Nokogiri/XML/SAX.html

Attributes

result[R]

Public Class Methods

new(platform) click to toggle source
# File lib/appium_lib/common/helper.rb, line 77
def initialize(platform) # rubocop:disable Lint/MissingSuper
  reset
  @platform = platform
end

Public Instance Methods

formatted_result() click to toggle source
# File lib/appium_lib/common/helper.rb, line 98
def formatted_result
  @result
    .sort_by { |_element, count| count }
    .reverse
    .reduce('') { |acc, element| "#{acc}#{element[1]}x #{element[0]}\n" }
    .strip
end
reset() click to toggle source
# File lib/appium_lib/common/helper.rb, line 82
def reset
  @result = Hash.new 0
end
start_element(name, attrs = []) click to toggle source

nokogiri.org/Nokogiri/XML/SAX/Document.html

# File lib/appium_lib/common/helper.rb, line 87
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