Reputation: 639
How to make selenium server 2.0 identify the sub-menu buttons that appear on hovering the mouse over menu buttons. For example, there is a menu button. On hovering the mouse over it, 2 sub-menu buttons appear. I want to click on the sub-menu button. How to make selenium server 2.0 identify the sub-menu button and click it?
Upvotes: 0
Views: 1856
Reputation: 4536
Try Below code by Updating findElement method's argument value:
//Find the main menu element
WebElement menu = driver.findElement(By.id("top_sell"));
//Perform mouse over action
Actions mouseMenu = new Actions(driver);
mouseMenu.moveToElement(menu).build().perform();
//Then find the sub menu element
WebElement subMenu = driver.findElement(By.cssSelector("a[href='/some_link'"));
//Now click on sub menu
subMenu.click();
Upvotes: 1