我试图将鼠标悬停在下面的span元素之上,其值为'获得特殊访问权限#39;但由于在同一个内部存在双跨元素,因此无法成功。
HTML代码段:
<div class="x-component x-box-item x-component-default x-menu-item x-menu-item-active" id="menuitem-1935" style="right: auto; left: 0px; top: 25px; margin: 0px; width: 250px;">
<a id="menuitem-1935-itemEl" class="x-menu-item-link" href="#" hidefocus="true" unselectable="on">
<div role="img" id="menuitem-1935-iconEl" class="x-menu-item-icon " style="">
</div>
<span id="menuitem-1935-textEl" class="x-menu-item-text" unselectable="on">
<span class="menu_item_head">Access</span> Get Special Access</span>
<img id="menuitem-1935-arrowEl" src="ext-4.2.1.883/resources/themes/images/default/tree/s.gif" class="x-menu-item-arrow">
</a>
</div>
我确实在下面试过,
browser.actions().mouseMove(element(by.xpath("//span[.= ' Get Special Access']"))).perform();
并最终出现错误:
Message:
Failed: No element found using locator: By(xpath, //span[.= ' Get Special Access'])
Stack:
NoSuchElementError: No element found using locator: By(xpath, //span[.= ' Get Special Access])
答案 0 :(得分:0)
您可以尝试使用以下定位器之一:
element(by.xpath("//*[@id='menuitem-1935-textEl']"))
element(by.xpath("//*[@id='menuitem-1935-textEl']//span"))