watir find "re td"
Let us assume that we are working with the table:
<table> <tr> <td>1a</td> <td>1b</td> </tr> <tr> <td>2a</td> <td>2b</td> </tr> </table>
Solution - Watir-Webdriver
The Table class has a strings method that returns the text of the table as a 2D array. The array is of rows, but you can use transpose to get it to be columns.
columns = browser.table(:id => "table").strings.transpose
p columns[0]
#=> ["1a", "2a"]
p columns[1]
#=> ["1b", "2b"]
Solution - Iteration
You can of course also iterate through each row and collect the cell in each column:
p browser.table(:id => "table").trs.collect{ |tr| tr[0].text }
#=> ["1a", "2a"]
p browser.table(:id => "table").trs.collect{ |tr| tr[1].text }