New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hover with native events on Windows is not persisted #2067

Closed
lukeis opened this Issue Mar 2, 2016 · 98 comments

Comments

@lukeis
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 2067

I have noticed that in Firefox (I am using 5), the moveToElement 
action is not persisted.  By "persisted", I mean that I can see the 
mouse over event triggered but then immediately stop.  When using 
Chrome & Opera, the "hover" continues until the next selenium action. 
This means that with FF, I cannot assert that the "hover" has 
triggered the correct behaviour because the attributes I have to check 
have changed back by the time I assert on them! As I said, Chrome & 
Opera work fine. 

Selenium Webdriver 2.0.0 (Java)
O/S Windows 7 & Windows XP
Firefox 5

Reported by wareham.robbie on 2011-07-18 08:16:28

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Is your real mouse cursor over the Firefox window? If so, forcing the real cursor not
to be over the real window may help.

Reported by dawagner on 2011-07-18 09:52:31

Member

lukeis commented Mar 2, 2016

Is your real mouse cursor over the Firefox window? If so, forcing the real cursor not
to be over the real window may help.

Reported by dawagner on 2011-07-18 09:52:31

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
No, I can confirm that my real mouse cursor is not over the firefox window

Reported by wareham.robbie on 2011-07-26 13:59:14

Member

lukeis commented Mar 2, 2016

No, I can confirm that my real mouse cursor is not over the firefox window

Reported by wareham.robbie on 2011-07-26 13:59:14

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I think this because Firefox Driver triggers a Hover event where as mouseover would
persist

Reported by wareham.robbie on 2011-08-15 07:36:40

Member

lukeis commented Mar 2, 2016

I think this because Firefox Driver triggers a Hover event where as mouseover would
persist

Reported by wareham.robbie on 2011-08-15 07:36:40

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Can this be fixed and kindly be prioritised to HIGH as hovering is quite common on web2.0
testing and not having this fixed is awful.

Reported by raghu.alapati1 on 2011-09-01 04:05:11

Member

lukeis commented Mar 2, 2016

Can this be fixed and kindly be prioritised to HIGH as hovering is quite common on web2.0
testing and not having this fixed is awful.

Reported by raghu.alapati1 on 2011-09-01 04:05:11

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I also face the same issue. But it's not only with firefox, it's problem with IE browser
too. I checked in FF 3.6, FF6, IE8 [and all these browsers problem persists]. However
in chrome it worked perfectly. Also sometimes even mouse over using [movetoelement]
itself is not getting performed on FF. Sometimes we are facing mouseover (element persistent)
issue, sometimes mouseover itself doesn't happen. The same test case which works once
doesn't work other time is really frustrating.
Note: I tried using Selenium 2.5.0, 2.6.0 & 2.7.0 (but no luck)

Can you please fix this issue asap.

Reported by pavithz on 2011-10-04 10:23:21

Member

lukeis commented Mar 2, 2016

I also face the same issue. But it's not only with firefox, it's problem with IE browser
too. I checked in FF 3.6, FF6, IE8 [and all these browsers problem persists]. However
in chrome it worked perfectly. Also sometimes even mouse over using [movetoelement]
itself is not getting performed on FF. Sometimes we are facing mouseover (element persistent)
issue, sometimes mouseover itself doesn't happen. The same test case which works once
doesn't work other time is really frustrating.
Note: I tried using Selenium 2.5.0, 2.6.0 & 2.7.0 (but no luck)

Can you please fix this issue asap.

Reported by pavithz on 2011-10-04 10:23:21

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
yes, please fix this.  This only works on Chrome and not the other browsers :(

Reported by glory.leung on 2011-10-06 16:54:15

Member

lukeis commented Mar 2, 2016

yes, please fix this.  This only works on Chrome and not the other browsers :(

Reported by glory.leung on 2011-10-06 16:54:15

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Marked!~

Reported by binken.zou on 2011-10-09 11:02:02

Member

lukeis commented Mar 2, 2016

Marked!~

Reported by binken.zou on 2011-10-09 11:02:02

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member

Reported by barancev on 2011-10-13 06:31:35

  • Labels added: Component-WebDriver, Browser-Firefox
Member

lukeis commented Mar 2, 2016

Reported by barancev on 2011-10-13 06:31:35

  • Labels added: Component-WebDriver, Browser-Firefox
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Issue 2636 has been merged into this issue.

Reported by barancev on 2011-10-13 07:20:51

Member

lukeis commented Mar 2, 2016

Issue 2636 has been merged into this issue.

Reported by barancev on 2011-10-13 07:20:51

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Issue 2193 has been merged into this issue.

Reported by barancev on 2011-10-13 07:21:34

Member

lukeis commented Mar 2, 2016

Issue 2193 has been merged into this issue.

Reported by barancev on 2011-10-13 07:21:34

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
First, it'd help to get a sample HTML demonstrating the problem - The internal hover
tests (using the WebDriver API) work well.
Second, there'll be a change to the moveToElement in the upcoming  release (2.10?).
I'd suggest trying again after this release (a sample page will yield a faster response,
of course). 

Reported by eran.mes on 2011-10-18 16:37:26

Member

lukeis commented Mar 2, 2016

First, it'd help to get a sample HTML demonstrating the problem - The internal hover
tests (using the WebDriver API) work well.
Second, there'll be a change to the moveToElement in the upcoming  release (2.10?).
I'd suggest trying again after this release (a sample page will yield a faster response,
of course). 

Reported by eran.mes on 2011-10-18 16:37:26

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
            var driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx");
 var action = new OpenQA.Selenium.Interactions.Actions(driver);
            action.MoveToElement(driver.FindElement(By.Id("ctl00_SampleContent_GridView1_ctl09_Label1"))).Perform();
            driver.FindElement(By.Id("ctl00_SampleContent_GridView1_ctl09_Label1")).Click();

Reported by binken.zou on 2011-10-18 18:39:59

Member

lukeis commented Mar 2, 2016

            var driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/HoverMenu/HoverMenu.aspx");
 var action = new OpenQA.Selenium.Interactions.Actions(driver);
            action.MoveToElement(driver.FindElement(By.Id("ctl00_SampleContent_GridView1_ctl09_Label1"))).Perform();
            driver.FindElement(By.Id("ctl00_SampleContent_GridView1_ctl09_Label1")).Click();

Reported by binken.zou on 2011-10-18 18:39:59

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I am writing some code using the latest 2.8.0 version. 

Reported by binken.zou on 2011-10-18 18:40:30

Member

lukeis commented Mar 2, 2016

I am writing some code using the latest 2.8.0 version. 

Reported by binken.zou on 2011-10-18 18:40:30

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Sorry for type the wrong ID in the line five should be "ctl00_SampleContent_GridView1_ctl09_LinkButton1"

Reported by binken.zou on 2011-10-18 18:43:04

Member

lukeis commented Mar 2, 2016

Sorry for type the wrong ID in the line five should be "ctl00_SampleContent_GridView1_ctl09_LinkButton1"

Reported by binken.zou on 2011-10-18 18:43:04

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
 var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("file:///C:/Users/binken/Desktop/SampleDetails.htm");
var action = new OpenQA.Selenium.Interactions.Actions(driver);
var element = driver.FindElement(By.Id("linkSampleFavourites"));
action.MoveToElement(element).Perform();
driver.FindElement(By.Id("favRemoveLink140075")).Click();


The code above should display a popup window with OK and Cancel
But it's not

Reported by binken.zou on 2011-10-18 19:28:43


- _Attachment: [demo.zip](https://storage.googleapis.com/google-code-attachments/selenium/issue-2067/comment-15/demo.zip)_
Member

lukeis commented Mar 2, 2016

 var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("file:///C:/Users/binken/Desktop/SampleDetails.htm");
var action = new OpenQA.Selenium.Interactions.Actions(driver);
var element = driver.FindElement(By.Id("linkSampleFavourites"));
action.MoveToElement(element).Perform();
driver.FindElement(By.Id("favRemoveLink140075")).Click();


The code above should display a popup window with OK and Cancel
But it's not

Reported by binken.zou on 2011-10-18 19:28:43


- _Attachment: [demo.zip](https://storage.googleapis.com/google-code-attachments/selenium/issue-2067/comment-15/demo.zip)_
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Using 2.11.0 moveToElement still does not hover on firefox (works on Chrome).  Any idea
when this will be resolved?

Reported by damien.hollis on 2011-11-02 02:59:00

Member

lukeis commented Mar 2, 2016

Using 2.11.0 moveToElement still does not hover on firefox (works on Chrome).  Any idea
when this will be resolved?

Reported by damien.hollis on 2011-11-02 02:59:00

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
An html snippet and client code would help answering this question.

Reported by eran.mes on 2011-11-02 04:26:11

Member

lukeis commented Mar 2, 2016

An html snippet and client code would help answering this question.

Reported by eran.mes on 2011-11-02 04:26:11

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Hi, eran, I have upload the demo.zip file , you may have a look at this!

Reported by binken.zou on 2011-11-02 08:30:00

Member

lukeis commented Mar 2, 2016

Hi, eran, I have upload the demo.zip file , you may have a look at this!

Reported by binken.zou on 2011-11-02 08:30:00

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I DO confirm that the script doesn't work. I am using WebDriver 2.9. when executing
the script with Firefox browser, the item is hover quickly. so that, the following
actions failed. 
My script is 
Actions builder = new Actions(driver);
builder.MoveToElement(myElement).Perform();   
anotherElement.Click() // failed of  course

Reported by tmsnhien on 2011-11-02 12:03:51

Member

lukeis commented Mar 2, 2016

I DO confirm that the script doesn't work. I am using WebDriver 2.9. when executing
the script with Firefox browser, the item is hover quickly. so that, the following
actions failed. 
My script is 
Actions builder = new Actions(driver);
builder.MoveToElement(myElement).Perform();   
anotherElement.Click() // failed of  course

Reported by tmsnhien on 2011-11-02 12:03:51

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Yeaa this is realy a show stopper for me as well.Before reading this article i tried
many option to click a submenu item in IE browser but no help .

My code looks like .

WebElement menu= driver.findElement(By.id("arr_ID_NEWLOANONLINE"));//this is the main
toolbar menu//
menu.click();

WebElement wc= driver.findElement(By.xpath("table[@class='mnuSubMenu_Base']/tbody/tr[1]/td[2]"));
//this is submenu first item//

new Actions(driver).moveToElement(wc).click.perform() //not clicking anywhere but script
execution moved forward.//

Please resolve this if its really a issue with IE/webdriver compatibility.









Reported by naveencha on 2011-11-09 12:13:58

Member

lukeis commented Mar 2, 2016

Yeaa this is realy a show stopper for me as well.Before reading this article i tried
many option to click a submenu item in IE browser but no help .

My code looks like .

WebElement menu= driver.findElement(By.id("arr_ID_NEWLOANONLINE"));//this is the main
toolbar menu//
menu.click();

WebElement wc= driver.findElement(By.xpath("table[@class='mnuSubMenu_Base']/tbody/tr[1]/td[2]"));
//this is submenu first item//

new Actions(driver).moveToElement(wc).click.perform() //not clicking anywhere but script
execution moved forward.//

Please resolve this if its really a issue with IE/webdriver compatibility.









Reported by naveencha on 2011-11-09 12:13:58

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
There are known issues with moveToElement on IE, and there are no good workarounds that
can be applied within the WebDriver code. For IE, you need to make sure that the physical
mouse cursor is not within the boundaries of the IE browser window for hovering to
work. However, let's try to restrict the comments of this issue to Firefox only, since
the IE issue is already known.

Reported by james.h.evans.jr on 2011-11-09 12:56:39

Member

lukeis commented Mar 2, 2016

There are known issues with moveToElement on IE, and there are no good workarounds that
can be applied within the WebDriver code. For IE, you need to make sure that the physical
mouse cursor is not within the boundaries of the IE browser window for hovering to
work. However, let's try to restrict the comments of this issue to Firefox only, since
the IE issue is already known.

Reported by james.h.evans.jr on 2011-11-09 12:56:39

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I'm looking into issues with the synthetic mouse. I'll update the bug after I fix some
of the existing issues, which may be related to this one.

Reported by eran.mes on 2011-11-09 16:37:44

Member

lukeis commented Mar 2, 2016

I'm looking into issues with the synthetic mouse. I'll update the bug after I fix some
of the existing issues, which may be related to this one.

Reported by eran.mes on 2011-11-09 16:37:44

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Have experienced similar issues myself lately. I was using a similar block of code that
others are using in this issue; an action chain to move to an element to trigger css
:hover and then a find_element().click() .

I found that finding an element did not play nicely with the action chain because when
you find_element the page may scroll to that element. In this case the mouse's position
may remain relative to the window but fall off the element you originally moved to.

I found the solution was to find both elements first, then compile the action chain
to do the move and the click in one chain. The action chain can click too, of course.
There's no need to only WebElement.click().

For (python) example:
click_target = self.selenium.find_element(*self._click_locator)
hover_element = self.selenium.find_element(*self._hover_locator)
        ActionChains(self.selenium).move_to_element(hover_element).move_to_element(click_target).click().perform()

Reported by campbell.zac on 2011-11-10 16:18:11

Member

lukeis commented Mar 2, 2016

Have experienced similar issues myself lately. I was using a similar block of code that
others are using in this issue; an action chain to move to an element to trigger css
:hover and then a find_element().click() .

I found that finding an element did not play nicely with the action chain because when
you find_element the page may scroll to that element. In this case the mouse's position
may remain relative to the window but fall off the element you originally moved to.

I found the solution was to find both elements first, then compile the action chain
to do the move and the click in one chain. The action chain can click too, of course.
There's no need to only WebElement.click().

For (python) example:
click_target = self.selenium.find_element(*self._click_locator)
hover_element = self.selenium.find_element(*self._hover_locator)
        ActionChains(self.selenium).move_to_element(hover_element).move_to_element(click_target).click().perform()

Reported by campbell.zac on 2011-11-10 16:18:11

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
We have the same issue under Firefox 7.x using latest WebDriver, version 2.12.0. This
is the worst issue we are aware with WebDriver.

Reported by sebtardif on 2011-11-11 23:23:45

Member

lukeis commented Mar 2, 2016

We have the same issue under Firefox 7.x using latest WebDriver, version 2.12.0. This
is the worst issue we are aware with WebDriver.

Reported by sebtardif on 2011-11-11 23:23:45

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Issue 2854 has been merged into this issue.

Reported by barancev on 2011-11-18 12:49:57

Member

lukeis commented Mar 2, 2016

Issue 2854 has been merged into this issue.

Reported by barancev on 2011-11-18 12:49:57

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Selenium dev team -

Is there a fix expected soon for firefox?


Reported by babum.testleaf on 2011-11-29 03:48:19

Member

lukeis commented Mar 2, 2016

Selenium dev team -

Is there a fix expected soon for firefox?


Reported by babum.testleaf on 2011-11-29 03:48:19

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
This is a problem for all drivers using native events on Windows.  It does not affect
Linux.

Reduced test-case added to the test suite: RenderedWebElementTest#testHoverPersists

Reported by dawagner on 2011-11-30 15:26:43

  • Labels added: Browser-IE, OpSys-Windows
Member

lukeis commented Mar 2, 2016

This is a problem for all drivers using native events on Windows.  It does not affect
Linux.

Reduced test-case added to the test suite: RenderedWebElementTest#testHoverPersists

Reported by dawagner on 2011-11-30 15:26:43

  • Labels added: Browser-IE, OpSys-Windows
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Issue 2970 has been merged into this issue.

Reported by dawagner on 2011-11-30 15:27:32

Member

lukeis commented Mar 2, 2016

Issue 2970 has been merged into this issue.

Reported by dawagner on 2011-11-30 15:27:32

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I've been using JQuery as a workaround to this in the meantime:

js.ExecuteScript("return $(\"a:contains('New')\").mouseover();");
js.ExecuteScript("return $(\"a:contains('Accounting')\").next(':eq(1)').mouseover();");
//js.ExecuteScript("return $(\"a:contains('Account')\").click();");

webDriver.FindElement(By.LinkText("Account")).Click();

So by using the Javascript Executor I am able to trigger the mouse events on a drop
down menu and then once the element is visible, using the normal FindElement method
works just fine.

Reported by mitcheloc on 2011-11-30 19:19:50

Member

lukeis commented Mar 2, 2016

I've been using JQuery as a workaround to this in the meantime:

js.ExecuteScript("return $(\"a:contains('New')\").mouseover();");
js.ExecuteScript("return $(\"a:contains('Accounting')\").next(':eq(1)').mouseover();");
//js.ExecuteScript("return $(\"a:contains('Account')\").click();");

webDriver.FindElement(By.LinkText("Account")).Click();

So by using the Javascript Executor I am able to trigger the mouse events on a drop
down menu and then once the element is visible, using the normal FindElement method
works just fine.

Reported by mitcheloc on 2011-11-30 19:19:50

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I was having a similar problem using FFDriver/java trying to access menu items in a
three layered menu but was able to pick it by chaining the events (as campbell described
above - thank you!).  I couldn't do findElement first as the menu items and submenus
weren't visible until I moved to the preceding element.  For this UI, user clicks Menu,
then hovers over MenuItemA to see SubMenuItem1. 

Menu
  MenuItemA
     SubMenuItem1
     SubMenuItem2
  MenuItemB

I'm using Page Objects and was able to reference them with their defined identifier
name.

To get to SubMenuItem1
Menu.click();
Actions builder = new Actions(driver);      builder.moveToElement(Menu).moveToElement(MenuItemA).moveToElement(SubMenuItem1).click().build().perform();

To get to SubMenuItem2 I needed an additional step to moveToElement(SubMenuItem1) first
and them moveToElement(SubMenuItem2) before clicking.


Reported by ccnnlltests on 2011-12-02 20:27:50

Member

lukeis commented Mar 2, 2016

I was having a similar problem using FFDriver/java trying to access menu items in a
three layered menu but was able to pick it by chaining the events (as campbell described
above - thank you!).  I couldn't do findElement first as the menu items and submenus
weren't visible until I moved to the preceding element.  For this UI, user clicks Menu,
then hovers over MenuItemA to see SubMenuItem1. 

Menu
  MenuItemA
     SubMenuItem1
     SubMenuItem2
  MenuItemB

I'm using Page Objects and was able to reference them with their defined identifier
name.

To get to SubMenuItem1
Menu.click();
Actions builder = new Actions(driver);      builder.moveToElement(Menu).moveToElement(MenuItemA).moveToElement(SubMenuItem1).click().build().perform();

To get to SubMenuItem2 I needed an additional step to moveToElement(SubMenuItem1) first
and them moveToElement(SubMenuItem2) before clicking.


Reported by ccnnlltests on 2011-12-02 20:27:50

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Hi,
Fist of all, my English is poor so please forgive me if I make mistakes....
I met with the same issue that mouseover worked well with chrome but totally failed
with FF. I find two solutions as follow:
1. Use JSP
   JavascriptExecutor js = (JavascriptExecutor)driver;
   js.executeScript("$('#" + this.getLocator() + "').children('a').mouseover()");
   then, you can find element, which was invisible before, as normal.
2. use action.moveToElement as follows:

   Actions builder = new Actions(driver);
   Action action = builder.moveToElement(target).build(); 

   String oldUrl = driver.getCurrentUrl();
   while(true){
    try {
        action.perform();
                driver.FindElement(By.Id("XXXXX")).Click();
        if(!this.driver.getCurrentUrl().equalsIgnoreCase(oldUrl)) break;
    } catch (Exception e) {}
   }

Reported by huangyichao@yahoo.com.cn on 2011-12-06 06:29:31

Member

lukeis commented Mar 2, 2016

Hi,
Fist of all, my English is poor so please forgive me if I make mistakes....
I met with the same issue that mouseover worked well with chrome but totally failed
with FF. I find two solutions as follow:
1. Use JSP
   JavascriptExecutor js = (JavascriptExecutor)driver;
   js.executeScript("$('#" + this.getLocator() + "').children('a').mouseover()");
   then, you can find element, which was invisible before, as normal.
2. use action.moveToElement as follows:

   Actions builder = new Actions(driver);
   Action action = builder.moveToElement(target).build(); 

   String oldUrl = driver.getCurrentUrl();
   while(true){
    try {
        action.perform();
                driver.FindElement(By.Id("XXXXX")).Click();
        if(!this.driver.getCurrentUrl().equalsIgnoreCase(oldUrl)) break;
    } catch (Exception e) {}
   }

Reported by huangyichao@yahoo.com.cn on 2011-12-06 06:29:31

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Does no one realize that a pure JavaScript implementation of mouse events (the so-called
"comment #64" solution) is *ALREADY* implemented in the IE driver?! Set the "nativeEvents"
capability to false using the mechanism appropriate for your language binding to use
it.

 The caveat here is that it turns off *all* native events, which has implications you
need to be aware of. The two biggest implications are thus: First, if your site shows
JavaScript alert() or confirm() dialogs, your WebDriver code will most likely hang
with an alert showing at some point. Second, if you try to do anything more than just
basic keyboard operations, you're likely to encounter issues, as properly simulating
all keyboard events is *really* complex due to the number of edge cases (extending
and collapsing selection ranges using the shift key, word boundary navigation using
the control key, home-end and page up-page down behavior in <textarea> elements, and
so on), and that functionality isn't done yet. 

This is also where it's time to point out that if you're not happy with the pace of
innovation or with the solutions we've implemented, that the development team welcomes
patches and contributions. I, for one, would be more than happy to assist anyone who'd
be interested in learning more about contributing. All I ask is that you engage with
us in a discussion about the project basic principles. Join us on the IRC channel (#selenium
on Freenode) and we'll be glad to chat more.

Reported by james.h.evans.jr on 2012-07-17 16:07:43

Member

lukeis commented Mar 2, 2016

Does no one realize that a pure JavaScript implementation of mouse events (the so-called
"comment #64" solution) is *ALREADY* implemented in the IE driver?! Set the "nativeEvents"
capability to false using the mechanism appropriate for your language binding to use
it.

 The caveat here is that it turns off *all* native events, which has implications you
need to be aware of. The two biggest implications are thus: First, if your site shows
JavaScript alert() or confirm() dialogs, your WebDriver code will most likely hang
with an alert showing at some point. Second, if you try to do anything more than just
basic keyboard operations, you're likely to encounter issues, as properly simulating
all keyboard events is *really* complex due to the number of edge cases (extending
and collapsing selection ranges using the shift key, word boundary navigation using
the control key, home-end and page up-page down behavior in <textarea> elements, and
so on), and that functionality isn't done yet. 

This is also where it's time to point out that if you're not happy with the pace of
innovation or with the solutions we've implemented, that the development team welcomes
patches and contributions. I, for one, would be more than happy to assist anyone who'd
be interested in learning more about contributing. All I ask is that you engage with
us in a discussion about the project basic principles. Join us on the IRC channel (#selenium
on Freenode) and we'll be glad to chat more.

Reported by james.h.evans.jr on 2012-07-17 16:07:43

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
James, that's interesting to know. So with native events off, IE uses javascript for
mouseover and with it on, it uses the native events implementation, whatever that uses?
Thanks for pointing this out.

Though I"m sure people would not want to put up with disabling native events unless
they really don't encounter the issue areas you mention. And it appears this alternative
option is only for IE. We still need or waiting for cross browser solution/fix.

Reported by mangaroo on 2012-07-17 16:30:02

Member

lukeis commented Mar 2, 2016

James, that's interesting to know. So with native events off, IE uses javascript for
mouseover and with it on, it uses the native events implementation, whatever that uses?
Thanks for pointing this out.

Though I"m sure people would not want to put up with disabling native events unless
they really don't encounter the issue areas you mention. And it appears this alternative
option is only for IE. We still need or waiting for cross browser solution/fix.

Reported by mangaroo on 2012-07-17 16:30:02

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Yes, native events means, "use OS-level mechanisms for simulating user input". Not using
native events means, "use JavaScript to simulate user input." The specific issues associated
with native events in IE are well-known[1]. 

Also, it's important to note that,  like the IE driver, the Firefox driver also has
the ability to use native events or not, using the same capability. In fact, native
events are turned off by default when you use the Firefox driver on Linux. Chrome is
really the outlier here, and you'd have to ask the Chromium team whether they respect
the nativeEvents capability

[1] http://jimevansmusic.blogspot.com/2012/06/whats-wrong-with-internet-explorer.html

Reported by james.h.evans.jr on 2012-07-17 16:57:05

Member

lukeis commented Mar 2, 2016

Yes, native events means, "use OS-level mechanisms for simulating user input". Not using
native events means, "use JavaScript to simulate user input." The specific issues associated
with native events in IE are well-known[1]. 

Also, it's important to note that,  like the IE driver, the Firefox driver also has
the ability to use native events or not, using the same capability. In fact, native
events are turned off by default when you use the Firefox driver on Linux. Chrome is
really the outlier here, and you'd have to ask the Chromium team whether they respect
the nativeEvents capability

[1] http://jimevansmusic.blogspot.com/2012/06/whats-wrong-with-internet-explorer.html

Reported by james.h.evans.jr on 2012-07-17 16:57:05

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
While less popular, what about OperaDriver? Is it an outlier too and have to ask that
project's team whether they respect nativeEvents as well?

And how about SafariDriver, which I believe currently doesn't support native events.
I recall there's planned work to support the interactions API which would be related
(issue 4136). Will it ever support native events (or no because of limitations of Safari
extensions along with Mac/Windows support).

Reported by mangaroo on 2012-07-17 18:04:28

Member

lukeis commented Mar 2, 2016

While less popular, what about OperaDriver? Is it an outlier too and have to ask that
project's team whether they respect nativeEvents as well?

And how about SafariDriver, which I believe currently doesn't support native events.
I recall there's planned work to support the interactions API which would be related
(issue 4136). Will it ever support native events (or no because of limitations of Safari
extensions along with Mac/Windows support).

Reported by mangaroo on 2012-07-17 18:04:28

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
A good general rule of thumb is to ask the group or team that writes and maintains the
driver code whether it supports setting the nativeEvents capability. The WebDriver
team owns the drivers for IE, Firefox, and Safari. Thus, in the matter of whether a
driver supports setting the nativeEvents capability, Firefox does, and has for a very,
very long time[1]; IE does, but disabling native events is a relatively recent change;
Safari doesn't, since it's architecture doesn't allow for the native code hooks necessary
to use native events. For Chrome, the source of truth is the Chromium team; for Opera,
the source of truth is Opera Software. It is a long-term goal of the WebDriver project
to not contain any browser-specific driver code. We'll see if the two closed-source
browser holdouts will get on board. 

[1] Mozilla is in the process of creating a version of the Firefox driver that they
will maintain. See https://developer.mozilla.org/en/Marionette/ for more details.

Reported by james.h.evans.jr on 2012-07-17 19:47:27

Member

lukeis commented Mar 2, 2016

A good general rule of thumb is to ask the group or team that writes and maintains the
driver code whether it supports setting the nativeEvents capability. The WebDriver
team owns the drivers for IE, Firefox, and Safari. Thus, in the matter of whether a
driver supports setting the nativeEvents capability, Firefox does, and has for a very,
very long time[1]; IE does, but disabling native events is a relatively recent change;
Safari doesn't, since it's architecture doesn't allow for the native code hooks necessary
to use native events. For Chrome, the source of truth is the Chromium team; for Opera,
the source of truth is Opera Software. It is a long-term goal of the WebDriver project
to not contain any browser-specific driver code. We'll see if the two closed-source
browser holdouts will get on board. 

[1] Mozilla is in the process of creating a version of the Firefox driver that they
will maintain. See https://developer.mozilla.org/en/Marionette/ for more details.

Reported by james.h.evans.jr on 2012-07-17 19:47:27

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
This issue was closed by revision r17545.

Reported by eran.mes on 2012-07-20 14:54:20

  • Status changed: Fixed
Member

lukeis commented Mar 2, 2016

This issue was closed by revision r17545.

Reported by eran.mes on 2012-07-20 14:54:20

  • Status changed: Fixed
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
So this fix should be in 2.26.0, correct?

Reported by lvskiprof on 2012-07-20 15:41:56

Member

lukeis commented Mar 2, 2016

So this fix should be in 2.26.0, correct?

Reported by lvskiprof on 2012-07-20 15:41:56

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Yes.
Also note that for Firefox, the mouse cursor must still be inside the window for hover
to work.

Reported by eran.mes on 2012-07-26 10:11:37

Member

lukeis commented Mar 2, 2016

Yes.
Also note that for Firefox, the mouse cursor must still be inside the window for hover
to work.

Reported by eran.mes on 2012-07-26 10:11:37

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I hadn't noticed a problem with Firefox, other than the lack of persistence
of the hover event, but if you maximize the browser I suppose that should
do it.  When running remotely through the grid, as I do, you have no
control over where the cursor is sitting.  I look forward to testing out
your fix.

Reported by lvskiprof on 2012-07-26 16:30:44

Member

lukeis commented Mar 2, 2016

I hadn't noticed a problem with Firefox, other than the lack of persistence
of the hover event, but if you maximize the browser I suppose that should
do it.  When running remotely through the grid, as I do, you have no
control over where the cursor is sitting.  I look forward to testing out
your fix.

Reported by lvskiprof on 2012-07-26 16:30:44

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Just wanted to ask/confirm, also in comparison to native driver requirements for mouse
hover (or mouseover), is the javascript workaround (comments 60, 64) also dependent
on mouse cursor being inside (or outside) of browser window, or is that workaround
less restrictive (though requiring javascript, making it less native approach)?

Just asking to clarify this since people might want to consider trade-offs. Having
to have cursor within browser window may or may not be feasible depending on one's
test setup.

Reported by mangaroo on 2012-07-26 17:45:55

Member

lukeis commented Mar 2, 2016

Just wanted to ask/confirm, also in comparison to native driver requirements for mouse
hover (or mouseover), is the javascript workaround (comments 60, 64) also dependent
on mouse cursor being inside (or outside) of browser window, or is that workaround
less restrictive (though requiring javascript, making it less native approach)?

Just asking to clarify this since people might want to consider trade-offs. Having
to have cursor within browser window may or may not be feasible depending on one's
test setup.

Reported by mangaroo on 2012-07-26 17:45:55

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Correct me if I'm wrong, but I believe that by injecting javascript, you are essentially
using a form of the non-native approach because you are using the browser to register
the click. Alternatively, the native approach employs O/S level commands to register
the click.  

In my opinion, there is much to be said for keeping native events turned on, and only
using the javascript injection method as a course of action when native events aren't
cutting it (because of a bug, because they haven't been implemented for the browser,
because of the way the site is constructed, etc). Seems like there are less trade-offs.


Brian

Reported by x.bgoad@reverbnation.com on 2012-07-26 17:55:49

Member

lukeis commented Mar 2, 2016

Correct me if I'm wrong, but I believe that by injecting javascript, you are essentially
using a form of the non-native approach because you are using the browser to register
the click. Alternatively, the native approach employs O/S level commands to register
the click.  

In my opinion, there is much to be said for keeping native events turned on, and only
using the javascript injection method as a course of action when native events aren't
cutting it (because of a bug, because they haven't been implemented for the browser,
because of the way the site is constructed, etc). Seems like there are less trade-offs.


Brian

Reported by x.bgoad@reverbnation.com on 2012-07-26 17:55:49

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
** This is not relegated to clicks only, I was just using it as an example, but includes
any mouse interactions such as mouse overs, as this Issue implies.

Brian

Reported by x.bgoad@reverbnation.com on 2012-07-26 17:58:05

Member

lukeis commented Mar 2, 2016

** This is not relegated to clicks only, I was just using it as an example, but includes
any mouse interactions such as mouse overs, as this Issue implies.

Brian

Reported by x.bgoad@reverbnation.com on 2012-07-26 17:58:05

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Understandable to use native events where possible. This is just an idealistic thought:
but it would be nice if there's a simple approach where if native events somehow don't
work, they'll fail with exception. Then user can catch it and use javascript injected
workaround.

So in this mouse hover example, if cursor is outside browser window, or it just doesn't
take affect somehow, it will throw exception, so we now have catch code that will use
the workaround. But I assume that's not possible in most cases. 

So it is just to always use native events and then when your test fails because the
native event approach didn't work, and you tried everything and it just doesn't work,
then you switch your code to use javascript injected method. No nice try/catch method,
just plain old debugging when test fails from native event related issue and you have
to look into the issue.

Reported by mangaroo on 2012-07-26 18:05:40

Member

lukeis commented Mar 2, 2016

Understandable to use native events where possible. This is just an idealistic thought:
but it would be nice if there's a simple approach where if native events somehow don't
work, they'll fail with exception. Then user can catch it and use javascript injected
workaround.

So in this mouse hover example, if cursor is outside browser window, or it just doesn't
take affect somehow, it will throw exception, so we now have catch code that will use
the workaround. But I assume that's not possible in most cases. 

So it is just to always use native events and then when your test fails because the
native event approach didn't work, and you tried everything and it just doesn't work,
then you switch your code to use javascript injected method. No nice try/catch method,
just plain old debugging when test fails from native event related issue and you have
to look into the issue.

Reported by mangaroo on 2012-07-26 18:05:40

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
In reply to comment #76 - I experience the exact opposite behavior.  In order for the
hover to work in Firefox, I need to have the real mouse cursor outside of the browser
window.

Maybe I've written the wrong code? I've tried a few variations, and they are listed
below (c#):

#1)
var clickMainNav = new Actions(_selenium);
clickMainNav.Click(mainNavElement);
IAction hover = clickMainNav.Build();
hover.Perform();

#2)
var clickMainNav = new Actions(_selenium);
clickMainNav.MoveToElement(mainNavElement);
IAction hover = clickMainNav.Build();
hover.Perform();

With option #1 - if the mouse is outside of the window - the menu dropDown that appears
upon hover remains displayed and I can continue to click the sub-menu item that I then
need to navigate to.

With option #2 - if the mouse is outside of the window - the menu dropDown that appears
upon hover just blinks real quick and then disappears.

Either with option #1 or #2 - if the mouse is inside of the window - the menu dropDown
never even appears.  The only thing I see happening is the mainNavElement get highlighted
for a second (as if it was about to execute the hover).


Below is my Firefox profile code.  I've tried the above 2 options with both EnableNativeEvents
= true and false.  I get same behavior described above either way.

if (Config["FFProfile"] == "False")
{
   var defaultProfile = new FirefoxProfile();
   defaultProfile.EnableNativeEvents = true;
   DesiredCapabilities FFCapability = DesiredCapabilities.Firefox();
                                         FFCapability.SetCapability(FirefoxDriver.ProfileCapabilityName,
defaultProfile);

   _selenium = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"),
FFCapability);

   _driver = (RemoteWebDriver)_selenium; //These 2 lines of code are to get access
   _mouse = _driver.Mouse;               //to IMouse in different method I use
}

if (Config["FFProfile"] == "True")
{
   var firefoxProfile = new FirefoxProfileManager().GetProfile("FirefoxProfile");
   firefoxProfile.EnableNativeEvents = true;
   DesiredCapabilities FFCapability = DesiredCapabilities.Firefox();
                                        FFCapability.SetCapability(FirefoxDriver.ProfileCapabilityName,
firefoxProfile);

   _selenium = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"),
FFCapability);

   _driver = (RemoteWebDriver)_selenium; //These 2 lines of code are to get access
   _mouse = _driver.Mouse;               //to IMouse in different method I use
}


The reason this is an issue for me is because when we run the tests on our CI system,
the real mouse ends up being inside the browser window and then the hover fails.  Any
words of advice would be much appreciated.  Thanks.

Reported by arosszay on 2012-08-16 15:07:33

Member

lukeis commented Mar 2, 2016

In reply to comment #76 - I experience the exact opposite behavior.  In order for the
hover to work in Firefox, I need to have the real mouse cursor outside of the browser
window.

Maybe I've written the wrong code? I've tried a few variations, and they are listed
below (c#):

#1)
var clickMainNav = new Actions(_selenium);
clickMainNav.Click(mainNavElement);
IAction hover = clickMainNav.Build();
hover.Perform();

#2)
var clickMainNav = new Actions(_selenium);
clickMainNav.MoveToElement(mainNavElement);
IAction hover = clickMainNav.Build();
hover.Perform();

With option #1 - if the mouse is outside of the window - the menu dropDown that appears
upon hover remains displayed and I can continue to click the sub-menu item that I then
need to navigate to.

With option #2 - if the mouse is outside of the window - the menu dropDown that appears
upon hover just blinks real quick and then disappears.

Either with option #1 or #2 - if the mouse is inside of the window - the menu dropDown
never even appears.  The only thing I see happening is the mainNavElement get highlighted
for a second (as if it was about to execute the hover).


Below is my Firefox profile code.  I've tried the above 2 options with both EnableNativeEvents
= true and false.  I get same behavior described above either way.

if (Config["FFProfile"] == "False")
{
   var defaultProfile = new FirefoxProfile();
   defaultProfile.EnableNativeEvents = true;
   DesiredCapabilities FFCapability = DesiredCapabilities.Firefox();
                                         FFCapability.SetCapability(FirefoxDriver.ProfileCapabilityName,
defaultProfile);

   _selenium = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"),
FFCapability);

   _driver = (RemoteWebDriver)_selenium; //These 2 lines of code are to get access
   _mouse = _driver.Mouse;               //to IMouse in different method I use
}

if (Config["FFProfile"] == "True")
{
   var firefoxProfile = new FirefoxProfileManager().GetProfile("FirefoxProfile");
   firefoxProfile.EnableNativeEvents = true;
   DesiredCapabilities FFCapability = DesiredCapabilities.Firefox();
                                        FFCapability.SetCapability(FirefoxDriver.ProfileCapabilityName,
firefoxProfile);

   _selenium = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"),
FFCapability);

   _driver = (RemoteWebDriver)_selenium; //These 2 lines of code are to get access
   _mouse = _driver.Mouse;               //to IMouse in different method I use
}


The reason this is an issue for me is because when we run the tests on our CI system,
the real mouse ends up being inside the browser window and then the hover fails.  Any
words of advice would be much appreciated.  Thanks.

Reported by arosszay on 2012-08-16 15:07:33

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Forgot to mention - I'm using Selenium dotnet 2.25.1 and FF14

Reported by arosszay on 2012-08-16 15:10:30

Member

lukeis commented Mar 2, 2016

Forgot to mention - I'm using Selenium dotnet 2.25.1 and FF14

Reported by arosszay on 2012-08-16 15:10:30

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
After a long struggle, the solution for me on IE was to set
'EnableNativeEvents = false' in the InternetExplorerOptions.

Reported by boaz.farkash on 2012-08-30 08:52:17

Member

lukeis commented Mar 2, 2016

After a long struggle, the solution for me on IE was to set
'EnableNativeEvents = false' in the InternetExplorerOptions.

Reported by boaz.farkash on 2012-08-30 08:52:17

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Mark

Reported by Mirror.Zou on 2012-09-07 05:39:39

Member

lukeis commented Mar 2, 2016

Mark

Reported by Mirror.Zou on 2012-09-07 05:39:39

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I don't understand the meaning of comment #85.

Reported by mangaroo on 2012-09-09 03:38:34

Member

lukeis commented Mar 2, 2016

I don't understand the meaning of comment #85.

Reported by mangaroo on 2012-09-09 03:38:34

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Comment #79 is right on the money: Native events will usually yield better results unless
there's a bug.

Again, test cases would be very helpful reproducing this. The only one I currently
have is detailed in issue #4535.

Reported by eran.mes on 2012-09-11 12:05:21

Member

lukeis commented Mar 2, 2016

Comment #79 is right on the money: Native events will usually yield better results unless
there's a bug.

Again, test cases would be very helpful reproducing this. The only one I currently
have is detailed in issue #4535.

Reported by eran.mes on 2012-09-11 12:05:21

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Hi All,

The mouse over functionality is not working as expected in Firefox where as it is working
fine for Chrome and IE9( For IE if we place the mouse out of the execution window its
working fine). I am using the webdriver method moveToElement().

Can any one find the solution please share with.

I am using selenium stand alone server 2.28.0 and latest IE and Chrome drivers. And
my Firefox is 18.0.1

Reported by kumar.sandeep528 on 2013-02-12 09:17:18

Member

lukeis commented Mar 2, 2016

Hi All,

The mouse over functionality is not working as expected in Firefox where as it is working
fine for Chrome and IE9( For IE if we place the mouse out of the execution window its
working fine). I am using the webdriver method moveToElement().

Can any one find the solution please share with.

I am using selenium stand alone server 2.28.0 and latest IE and Chrome drivers. And
my Firefox is 18.0.1

Reported by kumar.sandeep528 on 2013-02-12 09:17:18

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I don't see that 2.28.0 supports FF 18, so native events are probably broken.  Try downgrading
to FF 17 and it will probably work.

Reported by lvskiprof on 2013-02-12 20:02:21

Member

lukeis commented Mar 2, 2016

I don't see that 2.28.0 supports FF 18, so native events are probably broken.  Try downgrading
to FF 17 and it will probably work.

Reported by lvskiprof on 2013-02-12 20:02:21

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Does not work for me: Selenium 2.29.0, Python driver (via SST), Firefox 16 on Debian.

Drag works, but the mouseup event handler on the web page is not executed.

Reported by florian.sesser on 2013-02-13 15:48:13

Member

lukeis commented Mar 2, 2016

Does not work for me: Selenium 2.29.0, Python driver (via SST), Firefox 16 on Debian.

Drag works, but the mouseup event handler on the web page is not executed.

Reported by florian.sesser on 2013-02-13 15:48:13

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Agree with #66. My generation observation is that for FF on Windows, the physical mouse
needs to be within the window bounds for hover to not be 'undone'

a workaround that is silly for most cases but perhaps works fine for some cases is
to click on the body element right before the hover:

el = findElement(By.cssSelector(".myelem")); // element to hover on
findElement(By.cssSelector("body").click(); // without this, when mouse is not over
window, it fails to hover
new Actions(driver).moveToElement(el).build().perform(); // works only with line 2
present

Reported by binod80 on 2013-04-04 20:20:00

Member

lukeis commented Mar 2, 2016

Agree with #66. My generation observation is that for FF on Windows, the physical mouse
needs to be within the window bounds for hover to not be 'undone'

a workaround that is silly for most cases but perhaps works fine for some cases is
to click on the body element right before the hover:

el = findElement(By.cssSelector(".myelem")); // element to hover on
findElement(By.cssSelector("body").click(); // without this, when mouse is not over
window, it fails to hover
new Actions(driver).moveToElement(el).build().perform(); // works only with line 2
present

Reported by binod80 on 2013-04-04 20:20:00

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
If you are still suffering this we 'resolved' this on our Grid by using a Windows script
that moves the mouse to a set location (I can't remember, about (20,20) or thereabouts).
It checks and moves on a timed schedule. 

If somebody logs into the machine and fiddles with it then it will 'reset' itself.
This has been solid for us for about 9 months now. We considered building it into Grid
to trigger it from Grid events like browser start but as it is it's been reliable enough
we no longer felt the need.

Of course this doesn't really work if you're running locally, or testing on IE  :)

Reported by campbell.zac on 2013-04-04 21:22:53

Member

lukeis commented Mar 2, 2016

If you are still suffering this we 'resolved' this on our Grid by using a Windows script
that moves the mouse to a set location (I can't remember, about (20,20) or thereabouts).
It checks and moves on a timed schedule. 

If somebody logs into the machine and fiddles with it then it will 'reset' itself.
This has been solid for us for about 9 months now. We considered building it into Grid
to trigger it from Grid events like browser start but as it is it's been reliable enough
we no longer felt the need.

Of course this doesn't really work if you're running locally, or testing on IE  :)

Reported by campbell.zac on 2013-04-04 21:22:53

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
For all browsers,
action = new Action(driver);
action.moveToElement(parentItem).build.perform();

WebDriverWait wdw = new WebDriverWait(driver,100);
wdw.until(ExpectedConditions.elementToBeClickable(by));
driver.findElement(by).click();

For IE
ieCapabilities.setCapability("requireWindowFocus", true);
ieCapabilities.setCapability("enablePersistentHover", false);
For Chrome
Sleep(5000) before hovering and after hovering...

Reported by tmsnhien on 2013-05-09 12:29:33

Member

lukeis commented Mar 2, 2016

For all browsers,
action = new Action(driver);
action.moveToElement(parentItem).build.perform();

WebDriverWait wdw = new WebDriverWait(driver,100);
wdw.until(ExpectedConditions.elementToBeClickable(by));
driver.findElement(by).click();

For IE
ieCapabilities.setCapability("requireWindowFocus", true);
ieCapabilities.setCapability("enablePersistentHover", false);
For Chrome
Sleep(5000) before hovering and after hovering...

Reported by tmsnhien on 2013-05-09 12:29:33

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
@tmsnhien comment#93
Waiting 5sec before and after? That's a bad joke.

Reported by garfieldklonklon on 2013-08-27 11:27:18

Member

lukeis commented Mar 2, 2016

@tmsnhien comment#93
Waiting 5sec before and after? That's a bad joke.

Reported by garfieldklonklon on 2013-08-27 11:27:18

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
I am pretty confused about this. Some pages suggest turning native events on, others
off. When I turn them off drag and drop breaks, when I turn them on hover and click
actions break. I have over 200 tests and this area (simulating mouse events) has been
the biggest headache. I have been reduced to making hidden elements visible using JavaScriptExecutor
for the moment which is not ideal. Are there any Selenium definitive guidelines on
how to get this all to work reliably?

Reported by acarlonvsn on 2013-11-12 05:13:37

Member

lukeis commented Mar 2, 2016

I am pretty confused about this. Some pages suggest turning native events on, others
off. When I turn them off drag and drop breaks, when I turn them on hover and click
actions break. I have over 200 tests and this area (simulating mouse events) has been
the biggest headache. I have been reduced to making hidden elements visible using JavaScriptExecutor
for the moment which is not ideal. Are there any Selenium definitive guidelines on
how to get this all to work reliably?

Reported by acarlonvsn on 2013-11-12 05:13:37

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
no visibility of mouse over of comments
 #57 ,  
 #60,
 #64..
even though its succesfull, let me know ifyou are able to execute java script "mouse
over" with visibilty on safari

Reported by sashankgangi on 2013-11-26 11:02:15

Member

lukeis commented Mar 2, 2016

no visibility of mouse over of comments
 #57 ,  
 #60,
 #64..
even though its succesfull, let me know ifyou are able to execute java script "mouse
over" with visibilty on safari

Reported by sashankgangi on 2013-11-26 11:02:15

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member

Reported by eran.mes on 2014-10-29 11:02:31

Member

lukeis commented Mar 2, 2016

Reported by eran.mes on 2014-10-29 11:02:31

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Hi,
Does anyone know mouse over on safari browser on mac .tried solution #60.it didn't
work. 

Reported by attar.reshma on 2015-02-27 20:38:38

Member

lukeis commented Mar 2, 2016

Hi,
Does anyone know mouse over on safari browser on mac .tried solution #60.it didn't
work. 

Reported by attar.reshma on 2015-02-27 20:38:38

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
#99, there is a specific thread for this Safari issue:
https://code.google.com/p/selenium/issues/detail?id=4136

This defect is closed already.

Reported by cbaldan@daitangroup.com on 2015-03-24 21:55:57

Member

lukeis commented Mar 2, 2016

#99, there is a specific thread for this Safari issue:
https://code.google.com/p/selenium/issues/detail?id=4136

This defect is closed already.

Reported by cbaldan@daitangroup.com on 2015-03-24 21:55:57

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
#57 worked for me (thank you). This is the python version
  js_script = ''.join(["var elem = document.getElementById('",            
            element_id,                                                     
            "');",                                                              
            "if( document.createEvent) {",                                      
            "var evObj = document.createEvent('MouseEvents');",                 
            "evObj.initEvent( 'mouseover', true, false );",                     
            "elem.dispatchEvent(evObj);",                                       
            "} else if( document.createEventObject ) {",                        
            "elem.fireEvent('onmouseover');",                                   
            "}"])                                                               
        driver.execute_script(js_script)  

Reported by mike@adaptivetherapy.com on 2015-08-04 04:16:25

Member

lukeis commented Mar 2, 2016

#57 worked for me (thank you). This is the python version
  js_script = ''.join(["var elem = document.getElementById('",            
            element_id,                                                     
            "');",                                                              
            "if( document.createEvent) {",                                      
            "var evObj = document.createEvent('MouseEvents');",                 
            "evObj.initEvent( 'mouseover', true, false );",                     
            "elem.dispatchEvent(evObj);",                                       
            "} else if( document.createEventObject ) {",                        
            "elem.fireEvent('onmouseover');",                                   
            "}"])                                                               
        driver.execute_script(js_script)  

Reported by mike@adaptivetherapy.com on 2015-08-04 04:16:25

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member
Regarding comment 96, what is meant by "visibility"? That one doesn't see the mouse
actually move over or hover over the element of interest? Or that the hover/mouse over
doesn't trigger the hidden element to become visible even though the executed code
does not return failure/exception?

If the latter, javascript code (the mentioned workarounds) tend not to throw exceptions
for these mouse operations. It either works or not. 

Also, the workaround only works for elements hidden using javascript on the web site/application.
If it is hidden by CSS, the workaround doesn't work, and you may have to fiddle with
CSS styling to force it to show up instead, faked mouse events won't trigger it.

If the former, the javascript code to simulate the hover may or may not visually show
mouse action depending on the browser type and speed of the operation. But why would
one care in this case?

Reported by mangaroo on 2015-08-04 04:59:58

Member

lukeis commented Mar 2, 2016

Regarding comment 96, what is meant by "visibility"? That one doesn't see the mouse
actually move over or hover over the element of interest? Or that the hover/mouse over
doesn't trigger the hidden element to become visible even though the executed code
does not return failure/exception?

If the latter, javascript code (the mentioned workarounds) tend not to throw exceptions
for these mouse operations. It either works or not. 

Also, the workaround only works for elements hidden using javascript on the web site/application.
If it is hidden by CSS, the workaround doesn't work, and you may have to fiddle with
CSS styling to force it to show up instead, faked mouse events won't trigger it.

If the former, the javascript code to simulate the hover may or may not visually show
mouse action depending on the browser type and speed of the operation. But why would
one care in this case?

Reported by mangaroo on 2015-08-04 04:59:58

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 2, 2016

Member

Reported by luke.semerau on 2015-09-17 18:13:16

  • Labels added: Restrict-AddIssueComment-Commit
Member

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 18:13:16

  • Labels added: Restrict-AddIssueComment-Commit
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.