<div id="Template_ctl16_ctl01_Location1_TreeView" style="overflow:auto;display:block;" tabindex="0">
<div>
<table cellspacing="0" cellpadding="0" style="width:100%;">
<tbody>
<tr>
<td>
<div id="cubek1z1" class="nrf03d0190-m">
<table class="nrf03d0190-n" cellpadding="0">
<tbody>
<tr>
<td class="nrf03d0190-5" onmouseover="if(window._f$0)_f$4(this)">
<img class="nrf03d0190-0" alt="" src="/WebResource.axd?d=M7gWkIUDj3IRN9CBh9GLLzF4VuNso-dKy3Rotx5PGdC0uT3ydQno5rIb-NZmtrRHU0LzVzM8VyBHLkbIFzfsDBifsXik5X8cfF8dTTpyh1L9n2Y-L0bYn1s4tciLXrau0&t=634787380317074324">
</td>
<td onmouseover="if(window._f$0)_f$5(this)">
<img class="nrf03d0190-0" alt="" src="/WebResource.axd?d=7sz-askeAWhF9r519BFO7s5XwSCLvPpgGPOJYyJ_GLevh8OESKMb_rEoVjUoei4tRoBBcLE2t0k2ici5YCEklBIiUx9pRM4ms_q18X9HGDBhaxHQlS5wQ5h-v7WaMEtq0&t=634787380317074324">
</td>
<td class="nrf03d0190-7">
<div class="nrf03d0190-l" onmouseover="if(window._f$0)_f$2(this)">All Locations</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div style="visibility:hidden;font-size:1px;background-color:Silver;height:7px;" onmouseout="if(window._f$0)_f$50(this)" onmouseover="if(window._f$0)_f$4Z(this)"> </div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
目前我知道以下工作: //div[.='All Locations']//tr/td[2]//img
该语法将返回第二个正确的图像。然而,我想要做的是返回相同的图像,但也用主 div id 限定它(即 Template_ctl16_ctl01_Location1_TreeView),它需要这样做,因为网页中会有第二个表具有相同的内部文本值。
阅读了很多 xpath 文档,但无法将父函数和这方面拼凑在一起。
这是我当前的硒代码: var allLocationChkBox = WebBrowser.Current.FindElement(By.XPath("//div[.='All Locations']//td[2]//img")); allLocationChkBox.Click();
只需在单击复选框之前将 qualiyfing 主 div id 添加到变量中。
任何人都能够阐明这一点?
谢谢