1

I have been trying all possible answers that were provided for similar Query.

My lay-out Structure of the Menu:

MainMenu1 , Manimenu2.... etc Under Each Mainmenu

   Submenu1>Item1, Item2, Item3
   Submenu2>Item1, Item2, Item3
   Submenu3>Item1, Item2, Item3

To get to Item1 or Item2 or Item3, we have to move the mouse over and hover it over Mainmenu1>submenu1 and then click Item2

I was able to use mouse-hover command and get it open the Mainmenu but unable to get past it.

Any suggestions Please?

Thankyou.

jgillich
  • 71,459
  • 6
  • 57
  • 85
  • Did you use **AdvancedUserInteractions**, if yes then what happened? Please show us how did you try to handle this. – Priyanshu Oct 01 '14 at 12:24

2 Answers2

0

After mouse-hovering mainmenu1 you need to find submenu1 and then perform mouse-hover

        Actions builder = new Actions(driver); 
        WebElement mainmenu1 = driver.findElement(By.xxxxx());
        builder.moveToElement(mainmenu1 ).build().perform();
        Thread.sleep(500); //add a wait
        WebElement submenu1=  driver.findElement(By.xxxxx()); //Find the submenu
        builder.moveToElement(submenu1).click().build().perform();
        Thread.sleep(500);
Vignesh Paramasivam
  • 2,360
  • 5
  • 26
  • 57
  • Actions a = new Actions(driver); WebElement menuHoverLink = driver.findElement(By.cssSelector("#admin")); a.moveToElement(menuHoverLink); WebElement subLink = driver.findElement(By.cssSelector(".companyinfo")); a.moveToElement(subLink); Thread.sleep(5000L); WebElement subLink3 = driver.findElement(By.className("companyinfo")); a.moveToElement(subLink3); a.click(); a.build().perform(); Thread.sleep(5000L); WebElement subLink4 = driver.findElement(By.cssSelector("#admin >ul>li:nth-child(1)>ul>li:nth-child(3)>a>span")); actions.moveToElement(subLink4); a.click(); a.build().perform(); – Solomon Kappala Oct 01 '14 at 13:19
  • I can see it hover open; but not clicking it open; – Solomon Kappala Oct 01 '14 at 13:20
  • wait for it and click it – Vignesh Paramasivam Oct 01 '14 at 14:18
0

Try this, I think it will help you

 new Actions(wd)
    .moveToElement(
            wd.findElement(By
                    .linkText("MainMenu1")))
    .build().perform();
 Thread.sleep(500);
 wd.findElement(By.linkText("Item1")).click();
Juhi Saxena
  • 1,197
  • 11
  • 17