我正在尝试根据基本文本/正则表达式访问特定行的链接
示例,我想点击第二列文字为"现金余额 - 每日"的行中的链接第3栏将是我正在寻找的日期" 09-Sep-2013"并且单击的链接位于第6列。
<tbody>
<tr>
<td>498488.txt</td>
<td>Cash Balances - Daily</td>
<td>10 Sep-2013</span> </td>
<td>No </td>
<td class="Table_DataCelllast">
<a href="javascript:void(0)" id="ctl00_ContentPlaceHolder2_dtgrdListFiles_ctl02_lnkViewfile" onclick="javascript:dw('DownloadFilesView.aspx?DocFileID=9187191&DocFileType=.txt','','menubar=yes,scrollbars,resizable,status,location','525','700'); return false;">View File</a>
</td>
</tr>`
这就是我试图获取打印出来的链接
b.table.trs.each do |tr|
p tr.a.link
end
但我得到的只是这个
#<Watir::Anchor:0x1017df620 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017df300 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017defe0 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017decc0 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017de978 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017de608 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017de2e8 located=false selector={:tag_name=>"a"}>
#<Watir::Anchor:0x1017ddfc8 located=false selector={:tag_name=>"a"}>
任何帮助将不胜感激。
答案 0 :(得分:1)
您可以遍历行以查找具有指定文本的行。然后单击该行中的链接:
row = @browser.table.tbody.trs.find do |tr|
tr.td(:index => 1).text == 'Cash Balances - Daily' and
tr.td(:index => 2).text == '09-Sep-2013'
end
row.link(:text => 'View File').click