Class: FireWatir::TableRow

Inherits:
Element
  • Object
show all
Defined in:
lib/firewatir/elements/table_row.rb

Overview

Description: Class for Table row element.

Constant Summary

Constants inherited from Element

Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE

Constants included from Container

Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #inspect, #method_missing, #text, #to_s, #visible?, #wait

Methods included from Container

#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field

Methods included from JsshSocket

#js_eval, #js_eval_method, #jssh_socket, #read_socket

Constructor Details

#initialize(container, how, what) ⇒ TableRow

Description:

Initializes the instance of table row object.

Input:

- how - Attribute to identify the table row element.
- what - Value of that attribute.


34
35
36
37
38
39
# File 'lib/firewatir/elements/table_row.rb', line 34

def initialize(container, how, what)
  @how = how
  @what = what
  @container = container
  #super nil
end

Dynamic Method Handling

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

Instance Attribute Details

#element_nameObject

Returns the value of attribute element_name.



7
8
9
# File 'lib/firewatir/elements/table_row.rb', line 7

def element_name
  @element_name
end

Instance Method Details

#[](key) ⇒ Object

Description:

Get cell at specified index in a row.

Input:

key - column index.

Output:

Table cell element at specified index.


64
65
66
67
68
# File 'lib/firewatir/elements/table_row.rb', line 64

def [] (key)
  assert_exists
  arr_cells = cells
  return arr_cells[key - 1]
end

#cellsObject

Description:

Get array of all cells in Table Row

Output:

Array containing Table Cell elements.


89
90
91
92
93
94
95
96
97
# File 'lib/firewatir/elements/table_row.rb', line 89

def cells
  assert_exists
  arr_cells = get_cells
  row_cells = Array.new(arr_cells.length)
  for i in 0..arr_cells.length - 1 do
    row_cells[i] = TableCell.new(@container, :jssh_name, arr_cells[i])
  end
  return row_cells
end

#column_countObject

Description:

Gets the length of columns in table row.

Output:

Length of columns in table row.


48
49
50
51
52
# File 'lib/firewatir/elements/table_row.rb', line 48

def column_count
  assert_exists
  arr_cells = cells
  return arr_cells.length
end

#eachObject

Description:

Iterate over each cell in a row.


74
75
76
77
78
79
80
# File 'lib/firewatir/elements/table_row.rb', line 74

def each
  assert_exists
  arr_cells = cells
  for i in 0..arr_cells.length - 1 do
    yield arr_cells[i]
  end
end

#locateObject

Description:

Locate the table row element on the page.


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/firewatir/elements/table_row.rb', line 13

def locate
  @o = nil
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    @element_name = locate_tagged_element("TR", @how, @what)
  end
  @o = self
end