如何在下面给出的菜单中将鼠标悬停在 MainMenu 上选择并单击 SubMenu2?
- 菜单
- 子菜单1
- 子菜单2
我尝试使用下面给出的代码,但无法选择 submenu2。请提供线索
Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(By.cssSelector("#access > ul > li > a"));
actions.moveToElement(menuHoverLink);
WebElement subLink = driver.findElement(By.cssSelector("#access > ul > li > ul > li > a"));
actions.moveToElement(subLink);
actions.click();
actions.perform();