Mouse Hover NOT Working | Selenium Forum
M
Posted on 15/11/2015
Hi Ashish / All,

I am NOT able to select the submenu, please see the below code


=================

//Generate mouse hover event on main menu
Actions actions = new Actions(Page.driver);
WebElement moveonmenu = Page.driver.findElement(By.xpath("//*[@id='l1i7']/a"));
actions.moveToElement(moveonmenu).click().build().perform();

//Generate mouse hover event on sub menu
WebElement moveonsubmenu = Page.driver.findElement(By.xpath("//*[@id='l2i7_3']/a"));
actions.moveToElement(moveonmenu).moveToElement(moveonsubmenu).click().build().perform();

waitMenu.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='l2i7_3']/div[2]/div[1]/div/div/ul/li[1]/a")));

//Link on the SubMenu
WebElement movetoelement = Page.driver.findElement(By.xpath("//*[@id='l2i7_3']/div[2]/div[1]/div/div/ul/li[1]/a"));
actions.moveToElement(moveonmenu).moveToElement(moveonsubmenu).moveToElement(movetoelement).click().perform();

==========================

Its clicking main menu, followed the sub menu, BUT NOT THE LINK in the sub menu.. whats its going wrong ?

thanks in advance.

Regards
J

M
Replied on 15/11/2015

Would you be able to send the URL of website??


M
Replied on 15/11/2015

Thanks i sorted it.. looks like i was messing up with click and build and perform command....

Regards
J


M
Replied on 15/11/2015

the xpaths you're using will not work they will keep on changing. find more stable xpaths.


M
Replied on 16/11/2015

Thanks Ashish, I have replaced the xpath by ID to Xpath by link Text.

But the challange I face now is,,, it worked well in IE, but when I execute the same in FF.The Code is NOT Working...


Thanks in advance

Regards
J


M
Replied on 16/11/2015

what is the error?