Skip to content

Instantly share code, notes, and snippets.

@azakordonets
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azakordonets/fa76d835861d3b7217d1 to your computer and use it in GitHub Desktop.
Save azakordonets/fa76d835861d3b7217d1 to your computer and use it in GitHub Desktop.
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