我無法執行鼠標懸停操作。我鏈接所有這些我不得不執行的操作,但我不能達到正確的元素鼠標懸停問題
我的代碼
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