我正在探索自动化UI应用程序的选项。我有一个菜单,将显示子菜单在鼠标上。我无法单击子菜单项。
下面是我的html代码。
<table class="mnuAdmin_2" id="mnuAdmin" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td id="mnuAdminn0"
onmouseover="Menu_HoverStatic(this)"
onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="white-space: nowrap;">
<a class="mnuAdmin_1" style="cursor: text;" href="#">
<img style="vertical-align: middle;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;"
alt=""
src="Images/icon_administration.gif" />
Administration</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class="mnuAdmin_0 dynamicMenu mnuAdmin_5"
id="mnuAdminn0Items"
style="left: 165px;
top: 23px;
height: 101px;
display: inline;
visibility: visible;
z-index: 100;
clip: rect(auto, auto, auto, auto);">
<table style="top: 0px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 1px;">
<td></td>
</tr>
<tr title="Test1"
id="mnuAdminn1"
onmouseover="Menu_HoverDynamic(this)"
onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)">
<td>
<table width="100%"
class="mnuAdmin_4"
border="0"
cellspacing="0"
cellpadding="0">
<tbody>
<tr>
<td style="width: 100%;
white-space: nowrap;">
<a class="mnuAdmin_1 mnuAdmin_3"
href="javascript:openNewTabs(' Test1.aspx',
' Test1',
' Test1',
false)">
<div class="menuPadding">
Test1
</div>
</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="height: 1px;">
<td></td>
</tr>
<tr style="height: 1px;">
<td></td>
</tr>
<tr title="Manage NICE Group"
id="mnuAdminn2"
onmouseover="Menu_HoverDynamic(this)"
onmouseout="Menu_Unhover(this)"
onkeyup="Menu_Key(this)">
<td>
<table width="100%"
class="mnuAdmin_4"
border="0"
cellspacing="0"
cellpadding="0">
<tbody>
<tr>
<td style="width: 100%; white-space: nowrap;">
<a class="mnuAdmin_1 mnuAdmin_3"
href="javascript:openNewTabs('Test2.aspx',
'Test2',
'Test2',
false)">
<div class="menuPadding">
Test2
</div>
</a>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="height: 1px;">
<td></td>
</tr>
<tr style="height: 1px;">
<td></td>
</tr>
<tr id="mnuAdminn3"
onmouseover="Menu_HoverDynamic(this)"
onmouseout="Menu_Unhover(this)"
onkeyup="Menu_Key(this)">
<td>
<table width="100%"
class="mnuAdmin_4"
border="0"
cellspacing="0"
cellpadding="0">
<tbody>
<tr>
<td style="width: 100%; white-space: nowrap;">
<a class="mnuAdmin_1 mnuAdmin_3"
style="cursor: text;"
href="#">
<div class="menuPadding">
Test3
</div>
</a>
</td>
<td style="width: 0px;">
<img style="vertical-align: middle;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;"
alt="Expand"
src="/abc/WebResource.axd?
d=Q47Az1X7LOaP01DStAi2pDvM8t2PM3
zBTfT7Sah9glcZvljgU_O4sclltCDWejo
5HwZg0ZVGfOiJikirBgVVmAah_spY2-
yjejh4oSaW2XbzOqmK0&t=635294807132453548" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="height: 1px;">
<td></td>
</tr>
<tr style="height: 1px;">
</tr>
</tbody>
</table>
</div>
我试过以下两种选择。
var element=driverIE.FindElement(By.LinkText(“管理”));
动作动作=新动作(driverIE);
action.MoveToElement(element).Build().Perform();
driverIE.FindElement(By.LinkText("Test2")).Click();
最佳答案
尝试以下操作:
action.MoveToElement(element.Perform();
线程睡眠(5000L);
driverIE.FindElement(By.LinkText(“Test2”)).Click();
我想我们应该给点时间打开子菜单。