Ruby on Rails how to get every row of a specific column of table? Loop through rows?

856 Views Asked by At

I have this table like in the image showed below: I am using Ruby Watir to get every row of the first column.

https://dominiumestate.com/wp-content/uploads/2019/08/Capture.jpg

I have tried this but I can't get every row of the table only the first one with

puts t.tr(:index => 2, class: ['spy1xx']).td(:index => 0).font(class: ['spy14']).text 

t = browser.table(:index => 1).tbody()

 puts t.trs(:index => 2, class: ['spy1xx']).each do |s|
 puts s.td(:index => 0).font(class: ['spy14']).text
 end
1

There are 1 best solutions below

4
On

You will want to:

  1. Get a collection of the table rows
  2. Iterate through each row to get the specific cell text.

Try:

browser.trs(class: /spy1x/, onmouseover: true).map { |tr| tr.font(class: 'spy14').text }