Class: Watir::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/omni_browser/watir.rb

Instance Method Summary collapse

Instance Method Details

#child_print(*tag_names) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/omni_browser/watir.rb', line 7

def child_print (*tag_names)
  tags = tag_names.flatten
  tally = {}

  print_line = ->(element) {
    tally.find_add(element.tag_name)
    puts "<#{element.tag_name}> #{tally[element.tag_name] - 1} | #{element.text.inspect} | #{element.elements.size}"
  }

  if tags.size == 0
    work = ->(element) {
      print_line.call(element)
    }
  else
    work = ->(element) {
      print_line.call(element) if tags.include?(element.tag_name)
    }
  end

  self.elements.each { |element|
    work.call(element)
  }

  puts tally.to_yaml
  puts self.elements.size
  puts PRINT_LINE
end