我正在探索自动化UI应用程序的选项。我有菜单,鼠标悬停显示子菜单。我无法点击子菜单项。
<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(&#34; Administration&#34;)); 动作动作=新动作(driverIE);
action.MoveToElement(element).Build().Perform();
driverIE.FindElement(By.LinkText("Test2")).Click();
答案 0 :(得分:0)
请尝试以下操作:
action.MoveToElement(元件).Perform();
的Thread.sleep(5000L);
driverIE.FindElement(By.LinkText(&#34; Test2的&#34))。单击();
我认为我们应该给子菜单打开几秒钟。