Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void selectFromDropDownWithHover(String menuTitle, String menuItem, String locatorType) throws Exception {
Actions actions = new Actions(manager.getDriver());
//first we find the menu title on which we will hover mouse cursor
WebElement menuHoverLink = findElementByLocator(locatorType, menuTitle);
//now we hover it with mouse
actions.moveToElement(menuHoverLink).perform();
//let's find our menu item
WebElement menuItemElement = findElementByLocator(locatorType, menuItem);
actions.moveToElement(menuItemElement);
actions.click().build().perform();
}
public WebElement findElementByLocator(By locator) throws Exception {
return manager.getDriver().findElement(locator);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment