lib/watir/table.rb in watir-2.0.1 vs lib/watir/table.rb in watir-2.0.2.rc1

- old
+ new

@@ -245,17 +245,24 @@ class TableRow < Element TAG = "TR" def locate super - if @o # cant call the assert_exists here, as an exists? method call will fail - @cells = [] - @o.cells.each do |oo| - @cells << TableCell.new(@container, :ole_object, oo) - end + cells if @o + end + + def cells + return @cells if @cells + + @cells = [] + @o.cells.each do |c| + @cells << TableCell.new(@container, :ole_object, c) end + @cells end + + private :cells # Returns an initialized instance of a table row # * o - the object contained in the row # * container - an instance of an IE object # * how - symbol - how we access the row @@ -268,30 +275,30 @@ end # this method iterates through each of the cells in the row. Yields a TableCell object def each locate - 0.upto(@cells.length - 1) { |i| yield @cells[i] } + 0.upto(cells.length - 1) { |i| yield cells[i] } end # Returns an element from the row as a TableCell object def [](index) assert_exists - if @cells.length <= index + if cells.length <= index raise UnknownCellException, "Unable to locate a cell at index #{index}" end - return @cells[index] + return cells[index] end # defaults all missing methods to the array of elements, to be able to # use the row as an array # def method_missing(aSymbol, *args) # return @o.send(aSymbol, *args) # end def column_count locate - @cells.length + cells.length end # Returns (multi-dimensional) array of the cell texts in table's row. # # Works with th, td elements, colspan, rowspan and nested tables. @@ -361,14 +368,13 @@ @how = how @what = what super nil end - def ole_inner_elements + def __ole_inner_elements locate return @o.all end - private :ole_inner_elements def document locate return @o end