hover

351 views
Skip to first unread message

NormanChin

unread,
Apr 29, 2011, 6:42:04 PM4/29/11
to webdriver
The problem is that the hover() method has been removed from selenium-
server-standalone-2.0b3.jar.
What's the replacement?

In *2.0b2.jar, this is the code that was "working" (actually flaky):

RenderedWebElement rwe = (RenderedWebElement)
driver.findElement(...);
rwe.hover();

I replaced it with this and it seems to work for me:

WebElement we = driver.findElement(...);

ActionChainsGenerator builder = ((HasInputDevices)
driver).actionsBuilder();
Action hover = builder.moveToElement(we).build();
hover.perform();

Hope this helps!

Norman

Robin Lee Powell

unread,
May 9, 2011, 3:44:24 PM5/9/11
to webdriver
It looks like you're doing this from the Java client, correct?

Are you using RemoteDriver?

When you do this, does the hover response stay until you do something
else?

I ask because when I do this with IE from the Ruby binding via
RemoteDriver, the hover happens but then immediately goes away, and
I'm curious where in the chain the problem lies.

-Robin

Norman Chin

unread,
May 9, 2011, 10:22:30 PM5/9/11
to webd...@googlegroups.com
Yes, I'm doing this from a Java client.
I'm not using RemoteDriver.
 
On IE, the hover response does stay until I click a submenu item. At least to me, it works as expected.

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


Jim Evans

unread,
May 10, 2011, 2:48:07 PM5/10/11
to webdriver
The problem in IE is likely that your mouse pointer is physically over
the browser window when the hover happens. If your pointer is not over
the IE window while your test is running, I'd be interested to know if
you still see the hover response disappear after a brief period.

--Jim
> >http://groups.google.com/group/webdriver?hl=en.- Hide quoted text -
>
> - Show quoted text -

Binken

unread,
Jun 8, 2011, 4:51:10 AM6/8/11
to webd...@googlegroups.com
I also met some issue on hovering element.

Binken

unread,
Jun 8, 2011, 5:19:59 AM6/8/11
to webd...@googlegroups.com
Both the cursor in or out of the IE window, I have the same issue

ramnik

unread,
Jul 28, 2011, 2:20:50 PM7/28/11
to webdriver
were you guys able to find solution for this some issue ? If so, can u
please post the code.

As I m also facing the same issue ..he hover happens but then
immediately goes away until i do some action on the sub menu opened

thanks in advance

shen xieyin

unread,
Jul 29, 2011, 6:09:14 AM7/29/11
to webd...@googlegroups.com
hey, can you give a try with new Action(webdirver).moveTo(webelement).perform()?

2011/7/29 ramnik <ramni...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "webdriver" group.

ramnik kaur

unread,
Jul 29, 2011, 11:27:03 AM7/29/11
to webd...@googlegroups.com
thanks Shen ..

i will give it try now ..

ramnik kaur

unread,
Jul 29, 2011, 2:37:59 PM7/29/11
to webd...@googlegroups.com
Hello sheen,
it opens for me to show the hover menu ..but the menu does not stay and i could not select the menu for the context menu opened..
i m using FF 3.6 ?

have u seen such issue that hover menu does not stay for longer enough to select the element from the menu ?

any additional code you have used to make that work ?

thanks
ramnik

Moises Siles

unread,
Jul 29, 2011, 4:00:16 PM7/29/11
to webd...@googlegroups.com
Hi Ramnik,

I saw similar issues just a few times, but it works properly in most of the cases.... I'm doing something like this

            WaitForElement(By.XPath("locator"));
            webElement = FindElement(By.XPath("locator"));
            new Actions(webDriver).MoveToElement(webElement).Perform();

The only issue that I have is with nested menus where I need to hover at least 2 elements for example

     MainMenu
     SubMenu1
     Submenu2  ----- >
                               ------->NestedSubmenu2-1
                               ------->NestedSubmenu2-2     I need to click this element, but for some reason when I tried to click this, it will select the element inside the Submenu3
                               ------->NestedSubmenu2-3
     Submenu3
                               ------->NestedSubmenu3-1
                               ------->NestedSubmenu3-2


It works fine on IE, but I having that problem in FF, the only workaround that I found was to execute 2 times the selection, I tried with css, xpath and linktext

            WaitForElement(By.LinkText("MainMenu"));
            webElement = FindElement(By.LinkText("MainMenu"));
            new Actions(webDriver).MoveToElement(webElement).Perform();

            WaitForElement(By.LinkText("Submenu2"));
            webElement = FindElement(By.LinkText("Submenu2"));
            new Actions(webDriver).MoveToElement(webElement).Perform();
           
            WaitForElement(By.LinkText("NestedSubmenu2-2"));
            Click(By.LinkText("NestedSubmenu2-2"));     For some reason it is selecting the NestedSubmenu3-2 the first time

            //***************************************************************
            //WORKAROUND, Select the Element again and works fine
            ////***************************************************************
            
            WaitForElement(By.LinkText("MainMenu"));
            webElement = FindElement(By.LinkText("MainMenu"));
            new Actions(webDriver).MoveToElement(webElement).Perform();

            WaitForElement(By.LinkText("Submenu2"));
            webElement = FindElement(By.LinkText("Submenu2"));
            new Actions(webDriver).MoveToElement(webElement).Perform();
           
            WaitForElement(By.LinkText("NestedSubmenu2-2"));
            Click(By.LinkText("NestedSubmenu2-2"));


I'm not pretty sure but I think that the scroll action in the page could affect the hover execution when I tried to select the option that I want.

Regards

ramnik kaur

unread,
Jul 29, 2011, 4:42:44 PM7/29/11
to webd...@googlegroups.com
Thanks a lot ..i will try this suggestion now and let u know how it goes ..

thanks
ramnik

shen xieyin

unread,
Jul 30, 2011, 4:38:24 AM7/30/11
to webd...@googlegroups.com
hmmm, for ".but the menu does not stay and i could not select the menu for the context menu opened..", my guess is you can just add a wait after hover so that hover action keeps the menu stay, and then you can do the action on that menu, can u give a try?

2011/7/30 ramnik kaur <ramni...@gmail.com>

Danny Guerrier

unread,
Jul 30, 2011, 11:34:52 AM7/30/11
to webd...@googlegroups.com
I had the same issue and finally gave up on it and used the JavaScript executor to set the display to block then click what I needed. 

Moisés Siles

unread,
Jul 30, 2011, 2:31:31 PM7/30/11
to webd...@googlegroups.com, webd...@googlegroups.com
Hi Danny could you share a little bit your code to see how can I achieve that.... And then I can see if I have to change my current code 

Regards

Sent from my iPhone

Danny Guerrier

unread,
Aug 1, 2011, 9:51:04 AM8/1/11
to webd...@googlegroups.com
Just set the css display property of the element to block:

((JavascriptExecutor) driver).executeScript("arguments[0].style.display='block';", yourWebElement);

Reply all
Reply to author
Forward
0 new messages