0

I just want to click a sub menu from a menu dropdown using selenium webdriver. I tried with few of examples, but it is not working. Can you give logic for clicking a submenu item.

Srinivas
  • 1
  • 1
  • 1

1 Answers1

0

To perform a 'mouse hover' action, you need to concatenate all of the actions that you want to achieve in one go.

With the actions object you should first move to the dropdown, and then move to the dropdown item and click it.

Below is my attempt at sample code to perform Mouse hover;

//Move to the Dropdown    
Actions actions = new Actions(driver);
    WebElement dropdown = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("dropdown")));
actions.moveToElement(dropdown);

//Wait for the Dropdown Item to become available then click it    
    WebElement dropdownitem = wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("dropdownitem")));
    actions.moveToElement(dropdownitem);
    actions.click().build().perform();