Tuesday, February 16, 2016

Actions Class -- how to navigate to menu items

We have seen in previous post about actions

Go to site : amazon.in
and move to particular element using action class

More info : http://selenium.googlecode.com/svn@7074/trunk/docs/api/java/index.html



public class ActionsAmazon {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
WebDriver driver=new FirefoxDriver();
driver.get("http://www.amazon.in");
Thread.sleep(9000);
//*[@id="nav_grp"]/li[2]/a
WebElement item = driver.findElement(By.xpath("//*[@id='nav-link-shopall']/span[2]"));
// Actions class move to this item
Actions builder = new Actions(driver);
builder.moveToElement(item).build().perform();
Thread.sleep(3000);
}
}