class Appium::Common::HTMLElements
@private
Attributes
filter[R]
Public Class Methods
new()
click to toggle source
# File lib/appium_lib/common/helper.rb, line 217 def initialize # rubocop:disable Lint/MissingSuper reset @filter = false end
Public Instance Methods
characters(chars)
click to toggle source
# File lib/appium_lib/common/helper.rb, line 259 def characters(chars) return if @skip_element element = @element_stack.last element[:text] = chars end
end_element(name)
click to toggle source
# File lib/appium_lib/common/helper.rb, line 252 def end_element(name) return if filter && !filter.include?(name.downcase) element_index = @element_stack.rindex { |e| e[:name] == name } @element_stack.delete_at element_index end
filter=(value)
click to toggle source
convert to string to support symbols
# File lib/appium_lib/common/helper.rb, line 210 def filter=(value) # nil and false disable the filter return @filter = false unless value # rubocop:disable Lint/ReturnInVoidContext @filter = value.to_s.downcase end
reset()
click to toggle source
# File lib/appium_lib/common/helper.rb, line 222 def reset @element_stack = [] @elements_in_order = [] @skip_element = false end
result()
click to toggle source
# File lib/appium_lib/common/helper.rb, line 228 def result @elements_in_order.reduce('') do |r, e| name = e.delete :name attr_string = e.reduce('') do |string, attr| attr1 = attr[1] ? attr[1].strip : attr[1] "#{string} #{attr[0]}: #{attr1}\n" end return r if attr_string.nil? || attr_string.empty? "#{r}\n#{name}\n#{attr_string}" end end
start_element(name, attrs = [])
click to toggle source
# File lib/appium_lib/common/helper.rb, line 242 def start_element(name, attrs = []) @skip_element = filter && !filter.include?(name.downcase) return if @skip_element element = { name: name } attrs.each { |a| element[a[0]] = a[1] } @element_stack.push element @elements_in_order.push element end