以下是一段代碼,我已經復制了一條記錄(行)。我想從下面的代碼中搜索 selenium1 并洗掉該表的記錄。我已經分享了記錄在表格中的外觀的螢屏截圖。每條記錄的ID也不同。所以,我想根據匹配的文本洗掉記錄。請幫忙
<tr class="evenrow" id="S2D10925" onm ouseover="javascript:this.className='hilightrow';" onm ouseout="javascript:this.className='evenrow';" onclick="javascript:selectNode('S2D10925');">
<td align="left">
<img src="../images/icons/destinations\email3.png" style="vertical-align:middle;" width="16"
height="16">
SELENIUM1
</td>
<td nowrap="nowrap" align="left">Automation1</td>
<td nowrap="nowrap" align="left">INTERNET</td>
<td nowrap="nowrap" align="left">INTER_PROVIDER</td>
<td align="left">[email protected]</td>
<td align="left">[email protected]</td>
<td align="left">EMAIL</td>
<td nowrap="nowrap" align="left">(UTC-10:00) Hawaii</td>
<td nowrap="nowrap" align="left">Enabled</td>
</tr>
在此處輸入影像描述
uj5u.com熱心網友回復:
我會選擇 XPath。實作會因您使用的庫而異,但底層 Webdriver 支持 XPath。
示例 XPath,它將為您提供包含 td 和給定文本的 tr 節點
//tr[//td[contains(text(),'Automation1')]]
這是使用您的 html 片段的 Codepen:
https://codepen.io/chm-dev-the-selector/pen/dyVdLOa
如果您不熟悉 XPath,我強烈推薦此資源: https ://devhints.io/xpath 如果您想明白這一點,我發現它非常有用且時間有效,尤其是使用 XPath 測驗平臺(在頁面上提供) .
在類似的主題上也發現了這個: https ://www.guru99.com/using-contains-sbiling-ancestor-to-find-element-in-selenium.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/422259.html
標籤:
上一篇:allowMultipleSelectionDuringEditing不適用于自定義UITableviewCell
