I would like to go through a table and look for a word, if that word appears, i would like to click on a radio button in the same row, but not the same column, then stop the loop. I have something like this at the moment but i dont know where to go on from here.
@ie.div(:class, 'tableclass').table(:index, 1).each do | row |
row.ea开发者_如何学JAVAch do | cell |
if (cell.text() == 'text')
##Set radio button
break end end end
I tried selecting a radio by name and index, but i do not know how to get the row number that it is currently at. Thanks.
each_with_index is what you need. Something like this should work (not tested):
browser.div(:class, 'tableclass').table(:index, 1).rows.each_with_index do |row, index|
row.cells.each do |cell|
if cell.text == 'text'
browser.div(:class, 'tableclass').table(:index, 1)[index].radio(how, what).set
break
end
end
end
I could test it if you post relevant HTML snippet.
精彩评论