2015-12-16 31 views
0

所以我的問題是我試圖驗證例如「11305487/10」顯示時沒有給出事件中的tr單元格的值它在某個時候發生了變化。我希望它能瀏覽tr來尋找我提供的文本(),但似乎無法解決它。任何幫助表示讚賞!找到一個很多// tr的xpath而沒有給出確切的// tr [值]

firepath給我的

html/body/table[2]/tbody/tr/td/form/table/tbody/tr/td/table/tbody/tr[2]/td/div/table/tbody/tr[3]/td/div[1]/table/tbody/tr[4]/td[4] 

的XPath下面的XPath失敗

"//table[contains(div[1]/tr/td[4]/text(),'11618632')]" 



    <div id="scrollableDocumentsTable" onscroll="onScrollHideFilters();"> 
    <table id="documentsTable" width="960" cellspacing="1" cellpadding="0" border="0" align="center" style="table-layout: fixed;"> 
    <tbody> 
    <tr bgcolor="#008677"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
<td align="center"> 
<td class="BlackSmall" align="left" style="padding-left: 15px; padding-right: 5px;">09/25/14</td> 
<td class="BlackSmall" align="left" style="padding-left: 15px; padding-right: 5px;">10/25/14</td> 
<td class="BlackSmall" align="left" style="padding-left: 15px; padding-right: 5px;">11618632</td> 
<td class="BlackSmall" align="right" style="padding-left: 15px; padding-right: 5px;">71.54</td> 
<input id="bp_2" type="hidden" value="N" name="bp_2"/> 
<td class="BlackSmall" align="left" style="padding-left: 15px; padding-right: 5px;">Mail</td> 
<td class="BlackSmall" align="right" style="padding-left: 15px; padding-right: 5px;">0.00</td> 
<td class="BlackSmall" align="left" style="padding-left: 15px; padding-right: 5px;">xxxxxxxxxxx</td> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr height="19" bgcolor="#FFFF99"> 
    <tr height="19" bgcolor="#CCCCCC"> 
    <tr> 
    </tbody> 
    </table> 
    </div> 

回答

1

你可以使用// to recursively search all sub-nodes

"//table//td[contains(text(), '11618632')]" 

//table比賽所有table節點在文檔中。 //table//td匹配作爲table節點的後代的所有td節點。

td[contains(text(), '11618632')]將僅匹配td節點,其文本包含字符串'11618632'