After loggin the application, menu(image icon) is displayed at the left corner end. Once if we move the cursor on the icon, drop down list will show. In Firefox, its working but in chrome itsnot working. I have used the syntax "action.moveToElement(menu,0,0).click().build().perform();" its not working. Please assist me on this.
Asked
Active
Viewed 2,139 times
1 Answers
0
I think you are trying to click on the element too soon without waiting for it to display
Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(By.xpath(xpath));
actions.moveToElement(menuHoverLink);
WebElement subLink = driver.findElement(By.xpath(".//div[@id='nav']/div[@class='top-menu-for-more clearfix']/ul/li/a/span[text()='View All Courses']"));
actions.moveToElement(subLink);
//Now wait for sometime before clicking it
try
{
Thread.sleep(10000);
}
catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
actions.click().build().perform();
Let me know if it works for you

Fahim Hossain
- 1,671
- 13
- 16
-
I tried with above syntax, still i'm facing same issue. But its working in firefox. – VVV Aug 14 '14 at 05:55
-
Okay. I have a hunch here. Can you try to not click the element and see what happens. i.e. only execute the following: Actions actions = new Actions(driver); WebElement menuHoverLink = driver.findElement(By.xpath(xpath)); actions.moveToElement(menuHoverLink); – Fahim Hossain Aug 14 '14 at 06:00
-
My requirement is when mouser over the Menu image then system display dropdown list of A,B,C,D then mouse over B element then child element like B1,B2 etc displayed. Currently webdriver is recognised the menu image but dropdown list is not coming. Pls help me Fahim. – VVV Aug 14 '14 at 06:06
-
WebElement menu = driver.findElement(By.xpath("//*[@id='vMenu']/a")); Actions action = new Actions(driver); action.moveToElement(menu).perform(); Thread.sleep(1000); WebElement submenu = driver.findElement(By.linkText("Engineering")); Actions action1 = new Actions(driver); action1.moveToElement(submenu).perform(); System.out.println("Eng select"); Thread.sleep(1000); WebElement Chcktype = driver.findElement(By.linkText("Maintenance Facility")); Actions action2 = new Actions(driver); action2.moveToElement(Chcktype).click().perform(); – VVV Aug 14 '14 at 06:08
-
Okay in Chrome, it is not directly possible to do a mouse over action, one at a time. You have to chain the actions all together to perform a task. In your case, the code should look like this: WebElement menu = driver.findElement(By.xpath("//*[@id='vMenu']/a")); Actions action = new Actions(driver); action.moveToElement(menu).moveToElement(driver.findElement(By.linkText("Engineering")))).moveTOElement(By.linkText("Maintenance Facility").click().build().perform(); – Fahim Hossain Aug 14 '14 at 06:23
-
Site implementation differences sometimes make it difficult to pin-point the actual problem :( . My last bet would be WebElement menu = driver.findElement(By.xpath("//*[@id='vMenu']/a")); Actions action = new Actions(driver); action.moveToElement(menu).perform().moveToElement(submenu).perform(); //--> Here going to the inner child WebElement Chcktype = driver.findElement(By.linkText("Maintenance Facility")); //-->Locating the inner child to click on //Wait if needed here Chcktype.click(); --> click inner most child – Fahim Hossain Aug 14 '14 at 07:13
-
Else please take a look at this page for more answers http://stackoverflow.com/questions/17293914/how-to-perform-mouseover-function-in-selenium-webdriver-using-java – Fahim Hossain Aug 14 '14 at 07:16
-
Thanks Fahim. I tried your syntax also not worked. Thanks a lot for continous response. – VVV Aug 14 '14 at 08:50