Saturday, June 14, 2014

Use of Actions class

public class ClickCnChildMenu{
    public static void main(String[] args) {
        WebDriver driver=new FirefoxDriver();
        driver.get("http://new.mypomanager.com/Account/Login");
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.manage().window().maximize();
        driver.findElement(By.id("UserName")).sendKeys("retaileradmin");
        driver.findElement(By.id("Password")).sendKeys("password");
        driver.findElement(By.cssSelector("input[type='submit']")).click();
        WebElement parentmenu=driver.findElement(By.linkText("RETAILER"));
        Actions act=new Actions(driver);
        act.moveToElement(parentmenu).perform();
        WebElement createPO = driver.findElement(By.xpath("//a[contains(text(),'Create PO')]"));
        act.moveToElement(createPO).click().perform();
       
        }
}

3 comments:

  1. sanjay i have tried with same code but cursor will go to Create Po but click event is not triggering on Create PO..

    ReplyDelete
  2. Its clicking on Create Po right ?
    If you want to move the pointer as well then use Robot class.
    The above account has been removed so its not working it seems site is not available anymore.

    ReplyDelete
  3. while opening the url getting- HTTP Error 404.0 - Not Found

    ReplyDelete