我有一个JavaScript隐藏的下拉菜单,除非鼠标悬停在它上面,否则不会显示链接。我正尝试使用ruby watir-webdriver在此菜单中选择一个链接。我可以使用.hover选择链接,显示下拉菜单中的内容。但是我无法选择菜单中的任何链接。在这种情况下,我想点击链接“item1”。 下面是HTML代码:在JS隐藏下拉菜单中选择链接
<script type="text/javascript">
<div id="menuWHeader" class="menuWf">
<span class="menuTitle" onclick="goWindow(oprWin)" onmouseout="menuCollapse('menuWContent')" onmouseover="menuExpand('menuWContent')"> window </span>
<table id="menuWContent" class="menuContent" onmouseout="menuCollapse("menuWContent")" onmouseover="menuExpand("menuWContent")" style="visibility: hidden;">
<tbody>
<tr>
<td class="menuItemNormal" onclick="goWindow(oprWin)" onmouseout="menuNormal(this)" onmouseover="menuSelect(this)">
<img id="imgMenuWindow1" alt="" src="https://<myurl>/images/check-none.gif">
item1
</td>
</tr>
<tr style="display:none">
<td onclick="goWindow(crtWin)" onmouseout="menuNormal(this)" onmouseover="menuSelect(this)">
<img id="imgMenuWindow2" alt="" src="https://<myurl>/images/check-none.gif">
item2
</td>
</tr>
<tr>
<td class="menuItemNormal" onclick="goWindow(libWin)" onmouseout="menuNormal(this)" onmouseover="menuSelect(this)">
<img id="imgMenuWindow3" alt="" src="https://vts42.commstor.crossroads.com/images/check-none.gif">
item3
</td>
</tr>
第二个表行项目“ITEM2”是隐藏的,在菜单上不显示(代码灰色)。所以只有item1 & item3在我将鼠标悬停在菜单上时可以看到。
如前所述,我可以悬停在“窗口”这是该菜单的标题,然后显示菜单项。我无法选择列表中的任何项目。现在我只想选择item1。下面是要在菜单上悬停的watir代码。
wb.div(:id => 'menuWHeader').span(:class =>'menuTitle').hover
我试过一堆没有工作的东西,所以我没有看到发布我失败的尝试的任何一点。任何帮助表示赞赏。
工作完美谢谢! –