Selenium WebDriver-无法单击仅在单击并释放主菜单时显示的子菜单

Selenium WebDriver-无法单击仅在单击并释放主菜单时显示的子菜单,selenium,Selenium,我无法单击鼠标单击并释放时出现的子菜单 html标记: <div class="ToolbarSubMenu" id="presentations" onmouseout="actionToolbarMenuSubMenuExit('presentations');" align="left" style="text-align: left; left: 0px; top: 0px; z-index: 1000; visibility: hidden;" parent="prese

我无法单击鼠标单击并释放时出现的子菜单

html标记:

    <div class="ToolbarSubMenu" id="presentations" onmouseout="actionToolbarMenuSubMenuExit('presentations');" align="left" style="text-align: left; left: 0px; top: 0px; z-index: 1000; visibility: hidden;" parent="presentations_parent">
    <a id="hypothetical" class="ToolbarMenu" href="" onclick="onSelectMenuItem(201);;return false;">Hypothetical</a>
    <br><a id="profile" class="ToolbarMenu" href="" onclick="onSelectMenuItem(200);;return false;">Profile</a>
    <br><a id="rollingPeriods" class="ToolbarMenu" href="" onclick="onSelectMenuItem(542);;return false;">Rolling Periods</a>
    <br><a id="hiLo" class="ToolbarMenu" href="" onclick="onSelectMenuItem(540);;return false;">Hi / Lo</a>
    <br><a id="priceDistributions" class="ToolbarMenu" href="" onclick="onSelectMenuItem(541);;return false;">Price &amp; Distributions</a>
    <br><a id="exposureReport" class="ToolbarMenu" href="" onclick="onSelectMenuItem(204);;return false;">Exposure Report</a>
    <br>
</div>
<a id="presentations_parent" href="" class="ToolbarMenu" onclick="actionToolbarMenuClick('presentations');return false;">Presentations</a>

我有时会遇到移动到元素的问题,即拖放功能有点像moveToElement

我建议它不是单击您期望的元素

尝试通过标记/id等查找元素,并单击菜单和子菜单项


此外,如果出现动画,您需要允许一点延迟或使用waituntil功能来获取子菜单元素。

子菜单在鼠标悬停或单击时出现?您遇到了什么异常?子菜单在鼠标单击时出现…异常无法单击子菜单web元素感谢您的回复。我试过用id也没有成功。它点击主菜单->但子菜单闪烁并立即消失,用waituntil也尝试过,但它不起作用..伙计们,你们能帮我吗。。我被这个困住了!!不确定是否仍在使用moveToElement。
Actions act =new Actions(driver);

act.moveToElement(main).click().build().perform();   
act.release(main).build().perform();

 try {
    Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
    e.printStackTrace();
}

WebElement hyp=driver.findElement(By.linkText("Hypothetical"));
hyp.click();