Class: Watir::ElementCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/insite/examples/material_angular_io/watir_mods.rb

Instance Method Summary collapse

Instance Method Details

#to_aObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/insite/examples/material_angular_io/watir_mods.rb', line 36

def to_a
  hash = {}
  @to_a ||=
      elements.map.with_index do |e, idx|
        element = element_class.new(@query_scope, @selector.merge(element: e, index: idx))
        if [Watir::HTMLElement, Watir::Input].include? element.class
          tag_name = element.tag_name.to_sym
          hash[tag_name] ||= 0
          hash[tag_name] += 1
          Watir.element_class_for(tag_name).new(@query_scope, @selector.merge(element: e,
                                                                               tag_name: tag_name,
                                                                               index: hash[tag_name] - 1))
        else
          element
        end
      end
end