我正在尝试通过selenium自动化一个场景,我必须点击一个菜单元素,我尝试了除JQuery之外的所有内容。我尝试过普通的WebDriver点击,JavaScript点击(),但没有任何效果。任何人都可以帮助我在selenium中使用JQuery。
HTML:
<tr class="popUpMenuItemLo" onmouseenter="HighlightItem(this);ShowSubMenu('submenu11');">
<td align="middle" style="width:20px; background-Color:#FFF;"></td>
<td nowrap=" ">xyz</td>
<td width="20px" align="right">
<font face="webdings" size="2">4</font>
</td>
</tr>
我的代码:
//created the javascriptexecutor instance js
IWebElement getElement = driver().FindElement(By.Xpath("//td[contains(text(),xyz"));
js.ExecuteScript("$(argument[0]).mouseenter();", getElement);
我没有得到想要的结果,其中应该对元素执行mouseenter。
答案 0 :(得分:0)
您可以尝试使用操作类MoveToElement
并单击方法。或者使用jQuery,尝试使用mouseover()
和click()
:
js.ExecuteScript("$(argument[0]).mouseover();", getElement);