Class: SK::Row

Inherits:
Element show all
Defined in:
lib/table.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#el, #locator

Instance Method Summary collapse

Methods inherited from Element

#children, #displayed?, #enabled?, #exists?, #find, #find_child_el, #html, #parent_el, #search, #text

Constructor Details

#initialize(locator, index) ⇒ Row

Returns a new instance of Row.



30
31
32
33
# File 'lib/table.rb', line 30

def initialize(locator,index)
  super(locator) # creates the el and locator
  @index = index # remember your position
end

Instance Attribute Details

#indexObject (readonly)

row is an element that “remembers” it’s index in the table



28
29
30
# File 'lib/table.rb', line 28

def index
  @index
end

Instance Method Details

#cellsObject



35
36
37
38
# File 'lib/table.rb', line 35

def cells()
  ds = self.el.find_elements({tag_name: 'td'})
  ds.map.with_index { |e,i| SK::Cell.new(e,i) }
end

#to_sObject



40
41
42
43
# File 'lib/table.rb', line 40

def to_s
  text = cells.map { |cell| cell.text }.join("][")
  "<SK::Row #{@index} [#{text}] >"
end