lib/appium_lib/common/helper.rb in appium_lib-1.0.0 vs lib/appium_lib/common/helper.rb in appium_lib-2.0.0
- old
+ new
@@ -132,11 +132,13 @@
@result = Hash.new 0
end
# http://nokogiri.org/Nokogiri/XML/SAX/Document.html
def start_element name, attrs = []
- @result[name] += 1
+ # Count only visible elements. Android is always visible
+ element_visible = $driver.device_is_android? ? true : attrs.to_h['visible'] == 'true'
+ @result[name] += 1 if element_visible
end
def formatted_result
message = ''
sorted = @result.sort_by { |element, count| count }.reverse
@@ -145,10 +147,10 @@
end
message.strip
end
end # class CountElements
- # Returns a string of class counts.
+ # Returns a string of class counts of visible elements.
def get_page_class
parser = @count_elements_parser ||= Nokogiri::XML::SAX::Parser.new(CountElements.new)
parser.document.reset
parser.parse get_source
\ No newline at end of file