【发布时间】:2016-09-21 22:58:14
【问题描述】:
我遇到了一个问题,我认为问题在于我的 page.all 是如何拉出单选按钮问题的。
所以这是表格本身的 HTML(多个问题,每个问题有 5 个单选按钮选项):
<table class="table table-striped table-stuff table-collapsible">
<colgroup>
<thead>
<tbody>
<input id="0_answer_question_id" value="9966" name="response[answers][0][answer_id]" type="hidden">
<tr>
<td class="heading">
<td class="option">
<div class="radio-inline radio-inline--empty">
<input id="question_1_1" value="1" name="response[answers_attributes][0][answer_opinion]" type="radio">
<label for="question_1_1">Strongly Disagree</label>
</div>
</td>
<td class="option">
<td class="option">
<td class="option">
<td class="option">
</tr>
<input id="response_1_question_id" value="9966" name="response[answers_attributes][1][answer_question_id]" type="hidden">
<tr>
<input id="response_1_id" value="<a number>" name="response[answers_attributes][1][id]" type="hidden">
<Same as above repeated 5 times with numbers changed>
</tbody>
</table>
我正在使用:
page.all('table.table-stuff tbody tr', minimum: 6).each do |row|
row.all("td label").sample.trigger('click')
end
获取每一行并从中选择一个。但是,我注意到“有时”一行不会被选中。我的理论是“标题”(它本身有一个
当一个表被命名为table table-striped table-stuff table-collapsible...你怎么知道实际的表“名称”是什么? (我没有写这个网站,只是为它做测试)。当把它放在page.all('table.<etc>')?
【问题讨论】: