我无法执行鼠标悬停操作。我链接所有这些我不得不执行的操作,但我不能达到正确的元素鼠标悬停问题
我的代码
Actions action = new Actions(driver);
//1st Way
action.moveToElement(driver.findElement(By.xpath("//div[@arid='app1575']//a"))).moveToElement(driver.findElement(By.xpath("//div[@arid='app1589']//a"))).click().build().perform();
//2nd Way
action.moveToElement(driver.findElement(By.xpath("//div[@arid='app1575']//a"))).perform();
By locator = By.xpath("//div[@arid='app1589']//a");
driver.findElement(locator).click();
我的HTML
<div class="flyout" style="height:100%;left:0;overflow:visible;width:100%;">
<div class="root root_menu" style="width: 100%; height: 25px; overflow: visible; background-color: rgb(33, 136, 201); border-top: 1px solid rgb(25, 102, 151); border-bottom: 1px solid rgb(255, 255, 255);" lvl="0" arid="app1575" artype="NavBarItem" navmode="1" arwindowid="0">
<a class="btn" onclick="javascript:" style="width:213px;z-index: 1;">
<span class="navLabel root " style="width: 100%;color:#ffffff;">Quick Links</span>
</a>
<div class="flyout" style="overflow: visible; left: 0px; border-right: 1px solid rgb(25, 102, 151); display: none; visibility: hidden; position: absolute; top: -1px; margin-left: 100%; margin-right: 0px;">
<div class="item EP lvl1 " style="height: 25px; overflow: visible; background-color: rgb(106, 184, 233); border-left: 1px solid rgb(106, 184, 233); border-top: medium none; border-bottom: medium none;" lvl="1" arid="app1576" artype="NavBarItem" navmode="1" arwindowid="0">
<a class="btn" onclick="javascript:CallARGSHR_58LHP_58CHP_58AppListEntryPointperfarsvrgrp_46nat_46bt_46comEPFunc(false, this);" style="z-index: 1;">
<span class="navLabel lvl1 " style="color: rgb(255, 255, 255);">Home Page</span>
</a>
</div>
<div class="item EP lvl1 " style="height: 25px; overflow: visible; background-color: rgb(106, 184, 233); border-top: medium none; border-bottom: medium none;" lvl="1" arid="app1577" artype="NavBarItem" navmode="1" arwindowid="0">
<a class="btn" onclick="javascript:OpenAppWindow("/arsys/forms/perfarsvrgrp.nat.bt.com/AP%3AAdministration/Default+Administrator+View/?cacheid=d6be578&mode=CREATE",event);" style="z-index: 1;">
<span class="navLabel lvl1 " style="color: rgb(255, 255, 255);">Approval Administration Console</span>
</a>
</div>
<div class="item EP lvl1 " style="height: 25px; overflow: visible; background-color: rgb(106, 184, 233); border-top: medium none; border-bottom: medium none;" lvl="1" arid="app1578" artype="NavBarItem" navmode="1" arwindowid="0">
<a class="btn" onclick="javascript:OpenAppWindow("/arsys/forms/perfarsvrgrp.nat.bt.com/NGSD%3AITSM+Configuration/New+View/?cacheid=44bb87f8&mode=CREATE",event);" style="z-index: 1;">
<span class="navLabel lvl1 " style="color: rgb(255, 255, 255);">Customer Configuration</span>
</a>
</div>
<div class="item EP lvl1 " style="height: 25px; overflow: visible; background-color: rgb(106, 184, 233); border-top: medium none; border-bottom: medium none;" lvl="1" arid="app1579" artype="NavBarItem" navmode="1" arwindowid="0">
<a class="btn" onclick="javascript:OpenAppWindow("/arsys/forms/perfarsvrgrp.nat.bt.com/RJ%3ASQ2%3AProductCatalog/Default+Administrator+View__c/?cacheid=11b150e9",event);" style="z-index: 1;">
<span class="navLabel lvl1 " style="color: rgb(255, 255, 255);">RJ:SQ2:ProductCatalog</span>
</a>
</div>
什么是你所得到的例外呢?只是徘徊在“快速链接”结果下一级菜单?或者我们是否需要明确点击“快速链接”上的“右箭头”链接? –
没有例外或错误。是的,只需将鼠标悬停在下一级菜单中的快速链接上。 –
你能用代码打开第二个菜单吗?如果第二个菜单打开,那么尝试明确等待第二个菜单选项的可点击性,即以第二种方式在点击之前放置等待代码。 – Grasshopper