Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 关于表行和循环的Watir问题_Ruby_Loops_Watir - Fatal编程技术网

Ruby 关于表行和循环的Watir问题

Ruby 关于表行和循环的Watir问题,ruby,loops,watir,Ruby,Loops,Watir,我想在表格中查找一个单词,如果该单词出现,我想单击同一行但不是同一列中的单选按钮,然后停止循环。 我现在有类似的事情,但我不知道从现在开始该怎么办 @ie.div(:class, 'tableclass').table(:index, 1).each do | row | row.each do | cell | if (cell.text() == 'text') ##Set radio button break end end end 我尝试按名称和索引选

我想在表格中查找一个单词,如果该单词出现,我想单击同一行但不是同一列中的单选按钮,然后停止循环。 我现在有类似的事情,但我不知道从现在开始该怎么办

  @ie.div(:class, 'tableclass').table(:index, 1).each do | row |
     row.each do | cell |
    if (cell.text() == 'text')
      ##Set radio button
break end end end
我尝试按名称和索引选择收音机,但我不知道如何获取它当前所在的行号。谢谢。

正是您所需要的。类似的方法应该可以工作(未经测试):


如果您发布相关的HTML代码片段,我可以对其进行测试。

您是否仍然可以从外部访问row,只需执行以下操作:row.radio(how,what)。set谢谢您的回复。上面的单选按钮不工作。但用曼德森说的话来说,它是有效的。row.radio(:name,'radioButton')。set或browser.radio(:name=>radioButton',:index=>index)。set可以
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