我正在使用以下功能将鼠标悬停在菜单上并选择子项。它在Firefox和Chrome中运行良好,但似乎在IE中不起作用。在IE中,WebDriver可以找到'source'元素和'destination'元素,但是不会在'destination'元素上进行单击。 ('source'元素上的悬停在预期完成,'destination'元素显示.'destination'元素也会突出显示,但WebDriver无法点击该项目。)
public synchronized void mouseHoverOverMenuSelect(String SourceDisplayName, String DestinationDisplayName) {
Actions builder = new Actions(ex.driver);
WebElement source = getElement(SourceDisplayName);
Action mouseHoverover = builder.moveToElement(source).build();
mouseHoverover.perform();
WebElement destination = getElement(DestinationDisplayName);
mouseHoverover = builder.moveToElement(source).click(rm.element).release().build();
mouseHoverover.perform();
}
Selenium Standalone版本:2.31.0
IEDriverServer版本:2.25.2到2.32.3
平台:Windows 7
IE浏览器版本:9.0.8112.16421
请告诉我这里缺少的东西。
答案 0 :(得分:0)
以上功能使用了以下元素:
WebElement source = xpath(.//*[@id='Support']/span/a)
WebElement destination = linkText(Education Center)
菜单周围的HTML如下:
<UL id=mainMenu class=nav sizcache="6" sizset="0">
<LI id=Support onselectstart="return false;" onmouseover='setTimeout(function (){setBlocker("subMenuOfSupport")},10)' onmouseout=removeBlocker(); onmouseleave=removeBlocker(); onclick="javascript:activeMenu('Support');" ; valign="center" sizcache="6" sizset="12" jQuery1366868215713="18">
<SPAN align="center" sizcache="6" sizset="12">
<A onselectstart="return false;" onclick="showPage('Support');" target=contentMain>
<P style="WIDTH: 59px">Support </P>
<P class=down-arrow></P>
</A>
</SPAN>
<UL style="Z-INDEX: 1000; MARGIN: 38px 0px 0px -77px; DISPLAY: none" id=subMenuOfSupport sizcache="6" sizset="13" jQuery1366868215713="5">
<LI id="Education Center" onselectstart="return false;" class="last active" sizcache="6" sizset="13" jQuery1366868215713="19">
<A style="HEIGHT: 10px" onselectstart="return false;" onclick="showSearchCriteria('Education Center','educationCenter','subMenuOfSupport');" target=contentMain>Education Center</A>
</LI>
</UL>
</LI>
</UL>