Class: CapybaraPageObject::TableRowElement

Inherits:
Element
  • Object
show all
Includes:
Enumerable
Defined in:
lib/capybara_page_object/elements/table_row_element.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#element, #page

Instance Method Summary collapse

Methods inherited from Element

#attribute, #class, #enabled?, #focus, #html, #method_missing, #native, #parent, #respond_to_missing?, #scroll_into_view, #within

Constructor Details

#initialize(element, page, parent_table = nil) ⇒ TableRowElement

Returns a new instance of TableRowElement.



7
8
9
10
# File 'lib/capybara_page_object/elements/table_row_element.rb', line 7

def initialize(element, page, parent_table = nil)
  super(element, page)
  @parent_table = parent_table || find_parent_table
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CapybaraPageObject::Element

Instance Attribute Details

#parent_tableObject (readonly)

Returns the value of attribute parent_table.



5
6
7
# File 'lib/capybara_page_object/elements/table_row_element.rb', line 5

def parent_table
  @parent_table
end

Instance Method Details

#[](column_index) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/capybara_page_object/elements/table_row_element.rb', line 18

def [](column_index)
  if column_index.kind_of?(String)
    column_index = lookup_index_by_name(column_index)
  end

  return nil if column_index == nil
  columns[column_index]
end

#columnsObject



27
28
29
30
31
# File 'lib/capybara_page_object/elements/table_row_element.rb', line 27

def columns
  within do
    all(:xpath, ".//child::td|th")
  end
end

#eachObject



12
13
14
15
16
# File 'lib/capybara_page_object/elements/table_row_element.rb', line 12

def each
  for index in 1..self.columns.length do
    yield self[index-1]
  end
end