SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
346 stars 194 forks source link

MoveToElement in Firefox completely misses the element, if it is outside the viewport #7520

Open lukeis opened 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 7520

Hi!

I am using selenium to do browser-testing from C# and have found a problem when using
the built-in Firefox driver.
(The bug does not appear in Chrome or IE, only in Firefox)

I have included a minimal test case to help you reproduce it. 
It is a full Visual Studio console project in C#, which should be runnable out of the
box (Just press F5). 
The important files are "Program.cs" and "test.html".
(Notice the comment in "test.html" about how to make the test succeed, by moving the
target element inside the initial viewport)

DESCRIPTION OF THE PROBLEM: 
---------------------------

In firefox, when dragging and dropping an element A to a target element B, Selenium
will completely miss the target element B if it has to scroll the page in order to
hit element B. 
This happens both if you use the ".DragAndDrop(A,B)" action and if you use ".ClickAndHold(A).MoveToElement(B)"
actions (".Release()" not necessary to reproduce). 

It does not seem to overshoot the target, if the mouse-button is not held down while
it moves the mouse - so the action ".MoveToElement(A).MoveToElement(B)" seems to work
fine.
The bug thus seems to depend on whether the left mouse button is being held down during
the mouse movement or not.

The problem is old, but i used to be able to work around it, by "wiggeling" the mouse
a bit during the movement, before releasing the mouse button. 
I.e. ".ClickAndHold(A).MoveToElement(B).MoveByOffset(1,1).MoveToElement(B).Release()"
instead of ".ClickAndHold(A).MoveToElement(B).Release()".
This does however not work any longer in Firefox 30 (i do not remember which version
it worked in - maybe 25 or so).

In short:
If you move the mouse pointer while 1) the left mouse button is pressed and 2) you
move it to an element currently outside the viewport, Selenium will not move the mouse
pointer to the correct location.

If you have any problems reproducing the problem or need any further info, please let
me know.
Thanx for an awesome tool!

/Bjarke N. Laustsen

STANDARD INFO:
--------------

What steps will reproduce the problem?
1. Run selenium with the firefox driver (from C#)
2. Create code to drag an element, which is visible on the screen, and drop it on an
element outside the screen (or just move it to the element outside the screen without
releasing the mouse button)
3.

What is the expected output? 
The expected outcome is that selenium moves the mouse pointer to the target element
(and drops it there)

What do you see instead?
The actual outcome is that selenium moves the mouse pointer way below the target element
(and drops it there). It can easily miss by 1000 pixels or more. 
It is deterministic - it always hits the same "wrong location", given the same locations
of the input elements.

Selenium version: 2.42.0
OS: Windows 8
Browser: Firefox 
Browser version: 30.0
Language: C#

Code to reproduce the problem: 
------------------------------

C# code: See "Program.cs" in the attached example.
Html + JavaScript code: See "test.html" in the attached example.

Reported by bjarke@it-kartellet.dk on 2014-06-18 18:47:59


lukeis commented 8 years ago

Reported by barancev on 2014-06-23 20:19:50

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 17:47:02