How to select an element from a menu using Webdriver Selenium ? The Menu drop down shows up on Mouse Over?
You can check it in two ways: 1) first way is to use actions builder
WebElement mnuElement;
WebElement submnuElement;
mnEle = driver.findElement(By.Id("mnEle")).Click();
sbEle = driver.findElement(By.Id("sbEle")).Click();
Actions builder = new Actions(driver);
// Move cursor to the Main Menu Element
builder.MoveToElement(mnEle).Perform();
// Giving 5 Secs for submenu to be displayed
Thread.sleep(5000L);
// Clicking on the Hidden SubMenu
driver.findElement(By.Id("sbEle")).Click();
See here
2) another approach is to click directly needed element using jscript without simulating mouse hover event:
String cssLocatorOfTheElement=....//locator of the element to click on
JavascriptExecutor js = (JavascriptExecutor) driver;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("var x = $(\'"+cssLocatorOfTheElement+"\');");
stringBuilder.append("x.click();");
js.executeScript(stringBuilder.toString());
hope this works for you)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With