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.
Asked
Active
Viewed 3,151 times
0
-
Please add your code. – Ajit Pratap Singh Nov 17 '15 at 06:00
-
Hi, Actually i am new to selenium. Just i copied code from net and tried. – Srinivas Nov 17 '15 at 06:11
-
It's fine if you are new to selenium. Share that copied code here, so that users can analyze and provide solution with explanation. For sharing the code, edit your question and add it there. Avoid giving code in comments :) – MKay Nov 17 '15 at 06:49
1 Answers
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();

Emanuele Ciurleo
- 206
- 1
- 7