我想爲我的WebApp選擇菜單選項,能夠點擊菜單,菜單選項也可見但不能點擊菜單選項。無法點擊硒從菜單選項
如果我嘗試檢查菜單選項的可見性,那麼從Selenium API中可以看出它不可見,但實際上它已經可以在屏幕上看到。
是否有使用Selenium IE Driver選擇菜單和菜單選項的標準。
以下是菜單/菜單選項的代碼:
<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);
您正在嘗試的代碼是什麼?您可以在此粘貼嗎? –
@Abhi_Mishra感謝ABHI的答覆,我已經把我做過嘗試,但並沒有解決問題的四個採樣代碼。 – SmartSolution