我正在尝试为我的 WebApp 选择菜单选项,能够单击菜单,菜单选项也可见但无法单击菜单选项。
如果我尝试从 Selenium API 检查菜单选项的可见性,它说不可见,但实际上它已经在屏幕上可见。
是否有使用 Selenium IE 驱动程序选择菜单和菜单选项的标准。
以下是菜单/菜单选项代码:
<DIV style="BORDER-BOTTOM: 2px outset; POSITION: absolute; BORDER-LEFT: 2px outset; WIDTH: 162px; FONT-FAMILY: Tahoma; BACKGROUND: #e4e4e4; HEIGHT: 106px; FONT-SIZE: 8pt; BORDER-TOP: 2px outset; TOP: 0px; BORDER-RIGHT: 2px outset; LEFT: 0px">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(0,'smConfig0')"><SPAN>Config. Management</SPAN> </DIV><INPUT id=lgx_smConfig01 type=hidden SP="" LP="<LinkParams lgx_ID='WideDetail' FromDate='@Data.DefaultDate.FromDate~' ToDate='@Data.DefaultDate.ToDate~' lgx_DetailID='dtlConfig' FirstTime='1' ConfigType='2' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(1,'smConfig1')"><SPAN>Custom Configuration</SPAN> </DIV><INPUT id=lgx_smConfig11 type=hidden SP="" LP="<LinkParams lgx_ID='Default' lgx_ListID='lstCustomConfig' ConfigType='1' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(2,'smConfig2')"><SPAN>Custom Transition</SPAN> </DIV><INPUT id=lgx_smConfig21 type=hidden SP="" LP="<LinkParams lgx_ID='Default' lgx_ListID='lstCustomTransition' Flag='512' Title='Custom' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(3,'smConfig3')"><SPAN>Person Hierarchy Level</SPAN> </DIV><INPUT id=lgx_smConfig31 type=hidden SP="" LP="<LinkParams lgx_ID='Default' lgx_ListID='lstPersonLevel' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(4,'smConfig4')"><SPAN>Role</SPAN> </DIV><INPUT id=lgx_smConfig41 type=hidden SP="" LP="<LinkParams lgx_ID='Default' lgx_ListID='lstRoleConfig' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx">
<DIV style="PADDING-BOTTOM: 2px; PADDING-LEFT: 15px; PADDING-RIGHT: 2px; HEIGHT: 17px; COLOR: black; CURSOR: hand; PADDING-TOP: 2px" onmouseover="this.style.background='darkblue';this.style.color='white';" onmouseout="this.style.background=this.runtimeStyle.background;this.style.color='black';" onclick="parent.smConfig_Click(5,'smConfig5')"><SPAN>Status</SPAN> </DIV><INPUT id=lgx_smConfig51 type=hidden SP="" LP="<LinkParams lgx_ID='Default' lgx_ListID='lstStatusTy' />" Modal="" Features="" Target="_top" Action="lgx_Frame.aspx"> </DIV></DIV>
在上面的菜单选项代码中,我需要点击角色选项。此选项在单击配置菜单时可见,但单击任何此类菜单选项都不会发生,它也不会引发任何异常。
请让我知道您的意见或建议以解决此问题。
谢谢。
尝试代码1:
WebElement configMenu = driver.findElement(By.id("mConfigLabel"));
configMenu.click();
WebElement menuOption = driver.findElement(By.xpath("//div[@id='oMenuCntxtsmConfig']/div/div[4]"));
menuOption.click();
试过代码2:
WebElement configMenu = driver.findElement(By.id("mConfigLabel"));
configMenu.click();
WebElement menuOption = driver.findElement(By.xpath("//div/descendant:span[contains(text(),'Role']"));
menuOption.click();
尝试代码3:
configMenu.click();
Actions builder = new Actions(driver);
WebElement roleMenuOption = driver.findElement(By.xpath("//div[@id='oMenuCntxtsmConfig']/div/div[4]"));
builder.moveToElement(configMenu).click(roleMenuOption).build().perform();
尝试代码4:
WebElement configMenu = driver.findElement(By.id("mConfigLabel"));
configMenu.click();
WebElement roleMenuOption = driver.findElement(By.xpath("//div[@id='oMenuCntxtsmConfig']/div/div[4]"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", roleMenuOption);