Friday, May 8, 2015

Selecting sub menu while mouse hover top menu

In the above image Tools menu needs to be selected first and then sub menu should be selected.  In selenium webdriver the following package needs to be imported to use class Actions.

Use this class rather than using the Keyboard or Mouse directly. Implements the builder pattern: Builds a CompositeAction containing all actions specified by the method calls.

Pls. refer  http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html for action class methods and constructors.

To implement Actions class, the following package needs to be imported

import org.openqa.selenium.interactions.Actions;

linkText method of findElement method directly gets the link which has innerText within it. The below code can select the sub menu item.


Actions action = new Actions(driver);

WebElement mnuTools = driver.findElement(By.linkText("Tools"));

action.moveToElement(mnuTools).build().perform();

driver.findElement(By.linkText("Ad Copy Manager Internal")).click();



No comments: