5

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
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Astrit Shuli
  • 619
  • 4
  • 20

1 Answers1

0

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 }
Justin Ko
  • 46,526
  • 5
  • 91
  • 101
  • I have tried still shows the error of: #1, :tag_name=>"table"} --> {:tag_name=>"tr"} --> {:class=>"spy14", :tag_name=>"font"}> to be located; Watir treated ["scope"] as a non-HTML compliant attribute, ensure that was intended (Watir::Exception::UnknownObjectException) ...... im trying to get all the proxies and ports of this page http://spys.one/proxies/ – Astrit Shuli Aug 08 '19 at 08:20
  • @Rajagopalan can u help me in this topic too ? – Astrit Shuli Aug 08 '19 at 11:25
  • @AstritShuli, thanks for providing the actual page. Part of the problem is that the table you need is not the second one - `index: 1`. Updated the answer with a solution that finds the right rows without the table index. – Justin Ko Aug 08 '19 at 13:09
  • Thank you for everything – Astrit Shuli Aug 08 '19 at 16:09