How to mousehover and click on an element

456 views
Skip to first unread message

Maroof Ahmed Khan

unread,
Nov 15, 2014, 6:03:42 AM11/15/14
to seleniu...@googlegroups.com, webd...@googlegroups.com

Hi Guys,

I am learning selenium and want to perform mouse hover and logout action on www.flipkart.com website.




But my code is throwing org.openqa.selenium.StaleElementReferenceException

My code is:

Actions action = new Actions(driver);
WebElement we = driver.findElement(By.xpath(".//*[@class='no-border']"));
action.moveToElement(we).moveToElement(driver.findElement(By.xpath("//ul[@class='account-dropdown']//*[contains(@href,'logout')]"))).click().build().perform();

Please help


Regards,
Maroof


Robin Gupta

unread,
Nov 15, 2014, 10:15:13 AM11/15/14
to seleniu...@googlegroups.com
If Selenium aint helping you , you can try Sikuli jar too.

Jianfeng Sun

unread,
Nov 15, 2014, 1:26:49 PM11/15/14
to seleniu...@googlegroups.com, webd...@googlegroups.com
You only need one mouse move to Hi Testmak...!, and then click the option logout. Remember, selenium action is not real mouse move, but it is only to send message to html to trigger a like mouse movement action.  
As a human you move your mouse twice to finish that action, but not for machine.   

Mukesh otwani

unread,
Nov 16, 2014, 5:49:41 AM11/16/14
to seleniu...@googlegroups.com, webd...@googlegroups.com
Hi Maruf,

Give some wait and then try. use below link for mouse hover

http://www.learn-automation.com/2014/05/how-to-use-mouse-hover-in-selenium.html

Mark Collin

unread,
Nov 16, 2014, 10:19:34 AM11/16/14
to seleniu...@googlegroups.com
A StaleElementReferenceException means that the element you are trying to interact with no longer exists.

Assuming this is an Ajax heavy site is has probably been destroyed and recreated and your WebElement object is still pointing at the old one that has been destroyed.  It’s easy to fix, you just need to find you element again, in other words use the same .findElement() call that you used before.

Adding waits will not do anything, the original element no longer exists, you can wait as long as you like but it’s not coming back.

On 14 Nov 2014, at 07:10, Maroof Ahmed Khan <mahm...@gmail.com> wrote:


Hi Guys,

I am learning selenium and want to perform mouse hover and logout action on www.flipkart.com website.

<flipkart learning.jpg>


But my code is throwing org.openqa.selenium.StaleElementReferenceException

My code is:

Actions action = new Actions(driver);
WebElement we = driver.findElement(By.xpath(".//*[@class='no-border']"));
action.moveToElement(we).moveToElement(driver.findElement(By.xpath("//ul[@class='account-dropdown']//*[contains(@href,'logout')]"))).click().build().perform();

Please help


Regards,
Maroof



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAM4pecENRgS5FcewTBcQ6FHPA5jEN8%3DW1M6i2yypG7RsE_htHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Krishna Reddy Gtpv

unread,
Nov 16, 2014, 11:36:24 AM11/16/14
to seleniu...@googlegroups.com
Put some thread.sleep before that line..


For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards
Krishna Reddy Gtpv | Software Engineer | Anblicks Solutions Pvt Ltd
Blog : www.gtpvkr.in  | E Id  : gtp...@gmail.com | Ph : +91 - 9494585126

   




aravind hb

unread,
Nov 17, 2014, 3:03:47 AM11/17/14
to seleniu...@googlegroups.com, webd...@googlegroups.com
use FP


On Saturday, November 15, 2014 4:33:42 PM UTC+5:30, Maroof Ahmed Khan wrote:

CH!NN@ K

unread,
Nov 18, 2014, 7:20:19 AM11/18/14
to seleniu...@googlegroups.com

---
Thanks & Regards,
Purushotham Karimbedu,
Druapl Developer and QA Engineer,
Website for Selenium : http://techlearn.in


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages