所以我有一个看起来像这样的表格,其中有一个书籍列表,在第一列中,每本书都有两个链接,查看和删除。
我希望能够使用 Watir 找到具有指定书名的行,然后单击该书的查看按钮。
这是我到目前为止所拥有的
And /^click on View link of "(.*)" on the result set table$/ do |cell_name|
cellButton("submit.view", cell_name, "")
end
#
#
And /^click on Delete link of "(.*)" on the result set table with no_wait$/ do |cell_name|
cellButton("submit.delete", cell_name, "no_wait")
end
#
#
def cellButton(submit_type, s_name, s_wait_type)
c_found = 0
@browser.tables do |tbl|
tbl.rows do |r|
r.each do |c|
if c.text.to_s.matches(s_name)
c_found += 1
end
break if c_found > 0
end
if c_found > 0
if s_wait_type == "no_wait"
r.button(:name, submit_type).click_no_wait
else
r.button(:name, submit_type).click
end
end
break if c_found > 0
end
end
end
这是特定视图按钮的 html
<tr class="even">
<td class="actionColumn">
<span style="margin: 0px; padding: 0px; display: inline;">[</span>
<input id="013c6e2c8187_885b_1bd1f6fc" name="submit.view" class="action_link" size="" value="View" type="button" onclick="location.href='book_details.html'">
<span style="margin: 0px; padding: 0px; display: inline;">]</span><br>
<div>
<span style="margin: 0px; padding: 0px; display: inline;">[</span>
<input id="013c6e2c8187_1194_75ae28a8" name="submit.delete" class="action_link" size="" value="Delete" type="button">
<span style="margin: 0px; padding: 0px; display: inline;">]</span>
</div>
</td>
<td>
book title
<td>
<td>
more tds
</td>
</tr>
脚本运行时没有错误,但是没有按下视图链接。
我正在使用 Watir 4.0、Ruby 1.9.3 和 Cucumber 1.3.3