Class: Watir::Table
- Includes:
- TableCellsContainer, TableContainer, TableRowsContainer
- Defined in:
- lib/watir-classic/table.rb
Overview
Returned by Container#table
Instance Attribute Summary
Attributes inherited from Element
Attributes included from Container
Instance Method Summary collapse
-
#column_count(index = 0) ⇒ Fixnum
Number of columns inside of the table, including columns from nested tables.
-
#column_values(columnnumber) ⇒ Array<String>
Array of each row’s specified column text.
-
#hashes ⇒ Array<Hash>
Array with hashes of table data.
-
#row_count ⇒ Fixnum
Number of rows inside of the table, including rows from nested tables.
-
#row_values(rownumber) ⇒ Array<String>
Array of each column’s text on specified row.
- #to_s ⇒ Object
Methods included from TableCellsContainer
Methods included from TableRowsContainer
Methods included from TableContainer
Methods inherited from Element
#<=>, #attribute_value, #class_name, #click, #disabled?, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #focused?, #html, #id, #initialize, #inspect, #method_missing, #ole_object, #parent, #right_click, #send_keys, #style, #tag_name, #text, #title, #to_subtype, #unique_number, #visible?
Methods included from DragAndDropHelper
#drag_and_drop_by, #drag_and_drop_on
Methods included from Container
#a, #abbr, #address, #alert, #area, #article, #aside, #audio, #b, #base, #bdi, #bdo, #blockquote, #body, #br, #button, #canvas, #caption, #checkbox, #cite, #code, #col, #colgroup, #command, #data, #datalist, #dd, #del, #details, #dfn, #div, #dl, #dt, #element, #em, #embed, #fieldset, #figcaption, #figure, #file_field, #font, #footer, #form, #frame, #frameset, #h1, #h2, #h3, #h4, #h5, #h6, #head, #header, #hgroup, #hidden, #hr, #i, #img, #input, #ins, #kbd, #keygen, #label, #legend, #li, #map, #mark, #menu, #meta, #meter, #modal_dialog, #nav, #noscript, #object, #ol, #optgroup, #option, #output, #p, #param, #pre, #progress, #q, #radio, #rp, #rt, #ruby, #s, #samp, #script, #section, #select, #small, #source, #span, #strong, #style, #sub, #summary, #sup, #table, #tbody, #td, #text_field, #textarea, #tfoot, #th, #thead, #time, #title, #tr, #track, #u, #ul, #var, #video, #wbr
Methods included from Exception
Methods included from ElementExtensions
#present?, #wait_until_present, #wait_while_present, #when_present
Constructor Details
This class inherits a constructor from Watir::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Watir::Element
Instance Method Details
#column_count(index = 0) ⇒ Fixnum
97 98 99 100 |
# File 'lib/watir-classic/table.rb', line 97 def column_count(index=0) assert_exists rows[index].cells.length end |
#column_values(columnnumber) ⇒ Array<String>
105 106 107 |
# File 'lib/watir-classic/table.rb', line 105 def column_values(columnnumber) (0..row_count - 1).collect {|i| self[i][columnnumber].text} end |
#hashes ⇒ Array<Hash>
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/watir-classic/table.rb', line 118 def hashes assert_exists headers = [] @o.rows.item(0).cells.each do |cell| headers << TableCell.new(self, :ole_object => cell).text end rows_memo = [] i = 0 @o.rows.each do |row| next if row.uniqueID == @o.rows.item(0).uniqueID cells_memo = {} cells = row.cells raise "row at index #{i} has #{cells.length} cells, expected #{headers.length}" if cells.length < headers.length j = 0 cells.each do |cell| cells_memo[headers[j]] = TableCell.new(self, :ole_object => cell).text j += 1 end rows_memo << cells_memo i += 1 end rows_memo end |
#row_count ⇒ Fixnum
88 89 90 91 |
# File 'lib/watir-classic/table.rb', line 88 def row_count assert_exists rows.length end |
#row_values(rownumber) ⇒ Array<String>
112 113 114 |
# File 'lib/watir-classic/table.rb', line 112 def row_values(rownumber) (0..column_count(rownumber) - 1).collect {|i| self[rownumber][i].text} end |
#to_s ⇒ Object
147 148 149 150 151 152 |
# File 'lib/watir-classic/table.rb', line 147 def to_s assert_exists r = string_creator r += table_string_creator r.join("\n") end |