Class: Appium::Common::CountElements
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Appium::Common::CountElements
- Defined in:
- lib/appium_lib/common/helper.rb
Overview
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #formatted_result ⇒ Object
-
#initialize(platform) ⇒ CountElements
constructor
A new instance of CountElements.
- #reset ⇒ Object
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize(platform) ⇒ CountElements
Returns a new instance of CountElements.
62 63 64 65 |
# File 'lib/appium_lib/common/helper.rb', line 62 def initialize(platform) reset @platform = platform end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
60 61 62 |
# File 'lib/appium_lib/common/helper.rb', line 60 def result @result end |
Instance Method Details
#formatted_result ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/appium_lib/common/helper.rb', line 83 def formatted_result @result .sort_by { |_element, count| count } .reverse .each_with_object('') { |element, acc| acc << "#{element[1]}x #{element[0]}\n" } .strip end |
#reset ⇒ Object
67 68 69 |
# File 'lib/appium_lib/common/helper.rb', line 67 def reset @result = Hash.new 0 end |
#start_element(name, attrs = []) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/appium_lib/common/helper.rb', line 72 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 |