Java 使用selenium单击子菜单

Java 使用selenium单击子菜单,java,selenium,Java,Selenium,我想点击HTML代码的子菜单 <div class="appDiv"> <div class="hreftheme_AppLinks_sub_links_Li_Megamenu"> <a onclick="appSubmit('/ultimatixPortalWeb/portlets/applications/redirect.jsp?PARAM=236','236','_blank')" href="#"> Timesheet Ent

我想点击HTML代码的子菜单

<div class="appDiv">
    <div class="hreftheme_AppLinks_sub_links_Li_Megamenu">
        <a onclick="appSubmit('/ultimatixPortalWeb/portlets/applications/redirect.jsp?PARAM=236','236','_blank')" href="#"> Timesheet Entry </a>
        <span id="addTofavImage_236" class="favImage" onclick="" title=""> </span>
    </div>
</div>
(二)

(三)

(四)


也可以使用绝对xpath,但没有解决任何问题。

上述问题的HTML代码在您的问题中添加代码,而不是作为注释。感谢您提供的信息:您能帮助找到cssSelector(“我的子菜单项”)吗对于上面的HTML代码,很遗憾,我不能告诉您,因为我在您的代码中没有看到菜单或子菜单。如果您自己已经解决了这个问题,那么我上面的代码是否有助于回答您的问题。(我已经好几天没这么做了)上面问题的HTML代码div id=“parentGroup_26”class=“hreftheme\u AppLinks\u sub\u links\u div\u Megamenu”onmouseout=“removeParentHighlight('parent_26')”onmouseover=“highlightParent('parent_26')”style=“position:absolute;visibility:hidden;left:490px;”员工自助服务
Actions actions = new Actions(driver); 
WebElement menuHoverLink = driver.findElement(By.linkText("My Sub Menu"));
actions.moveToElement(menuHoverLink).perform();
driver.findElement(By.cssSelector("My Sub Menu Item")).click();
action.moveToElement(driver.findElement(By.linkText(Link name))).click().build().perform();
driver.findElement(By.linkText(str)).click();
// JavascriptExecutor executor = (JavascriptExecutor)driver;
         //executor.executeScript("arguments[0].click();", webelement for link );
driver.findElement(By.xpath(".//*[@id='parentGroup_26']/div[1]/table/tbody/tr/td[1]/div/div[12]/div/a")).click();
Actions actions = new Actions(driver); 
WebElement menuHoverLink = driver.findElement(By.linkText("My Sub Menu"));
actions.moveToElement(menuHoverLink).perform();
driver.findElement(By.cssSelector("My Sub Menu Item")).click();