使用selenium在DOM层次结构中向上移动

vip*_*169 0 selenium dom webdriver

我想访问一个DOM元素,它位于层次结构之上,是我有权访问的元素.

在Attached ScreenShot中,我想访问#nRD_1的Grand Grand Grand Parent的#pRow_22.但我只能访问#ntsDiv_1.请建议我在这种情况下做什么

在此输入图像描述

HTML代码是这样的: -

<tr id="pRow_22" style="border-bottom: 0;">
<td class="nameCell" style="border-bottom: 1px solid #CCCCCC;">
    <div id="seller_22" class="product-sellercell">
        <a id="pLogoLink_22" target="_blank" href="/norob/ClickTracker.somethins..." onclick="setMerchLb('eComElectronics.com')" rel="nofollow">
        <div>
            <a id="ntsLink_1" rel="nofollow" onclick="return false;" href="#">
        </div>
        <div id="ntsDiv_1" class="mlt-pop-container" style="width: 250px; text-align: left; white-space: normal; top: 2340px; left: 131px; visibility: hidden;">
            <div class="mlt-pop-bg">
        </div>
        .
        .   
        </div>
</td>
Run Code Online (Sandbox Code Playgroud)

Sta*_*ion 5

尝试使用xpath

.//a[contains(@id,'ntsLink_1')]/ancestor::tr
Run Code Online (Sandbox Code Playgroud)