Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

HTML 5 drag and drop in Firefox does not work #6315

Closed
lukeis opened this issue Mar 4, 2016 · 6 comments
Closed

HTML 5 drag and drop in Firefox does not work #6315

lukeis opened this issue Mar 4, 2016 · 6 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 6315

What steps will reproduce the problem?
======================================
The problem can easily be reproduced on the public page http://www.w3schools.com/html/html5_draganddrop.asp.
For instance, using the Python bindings:

from selenium.webdriver import Firefox
from selenium.webdriver.common.action_chains import ActionChains
ff = Firefox()
ff.get("http://www.w3schools.com/html/html5_draganddrop.asp")
source = ff.find_element_by_id('drag1')
target = ff.find_element_by_id('div2')
ActionChains(ff).drag_and_drop(source, target).perform()

What is the expected output? What do you see instead?
=====================================================
I would expect the "w3schools.com" image to be dragged and dropped onto the right div
(/box).
Instead, the last command ActionChains(..)... blocks until I move my mouse cursor over
the Firefox window. Then, the command returns but the image was not dragged.

This also happens when native events are enabled:

from selenium.webdriver import Firefox, FirefoxProfile
from selenium.webdriver.common.action_chains import ActionChains
profile = FirefoxProfile()
profile.native_events_enabled = True
ff = Firefox(profile)
ff.get("http://www.w3schools.com/html/html5_draganddrop.asp")
source = ff.find_element_by_id('drag1')
target = ff.find_element_by_id('div2')
ActionChains(ff).drag_and_drop(source, target).perform()

Selenium version: Python-2.35.0
OS: 64 bit Windows 7
Browser: Firefox
Browser version: 23.0.1

Many other users seem to be having the same problem:
 * http://stackoverflow.com/questions/18059684/issue-with-drag-and-drop-element-in-selenium-web-driver-with-java
 * http://stackoverflow.com/questions/16081075/unable-to-perform-drag-and-drop-using-selenium-webdriver
 * http://stackoverflow.com/questions/12117640/selenium-webdriver-not-working-for-html5-drag-and-drop
 * http://stackoverflow.com/questions/9797462/html5-drag-and-drop-using-selenium-webdriver-for-ruby

A fix for this would be greatly appreciated. I tried to work around the problem using
JavaScript, but to no avail.

Reported by mherrmann.at on 2013-09-24 14:10:12


- _Attachment: [draggable.html](https://storage.googleapis.com/google-code-attachments/selenium/issue-6315/comment-0/draggable.html)_
@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-09-25 11:57:42

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I'm facing the same issue will my scenario as well however with - 

Selenium version: Python-2.39.0.0
OS: 64 bit Windows 7
Browser: Firefox
Browser version: 26

Code (C#):

public void DragAndDropControl(IWebElement sourceControl, IWebElement targetControl)
{
    Actions ac = new Actions(Driver);
    ac.DragAndDrop(sourceControl, targetControl);
    ac.Build().Perform();
}

Any chances that this could be fixed soon?

Reported by vaibhav.lists on 2014-01-31 13:12:33

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I recently ran into this issue as well. I found a JavaScript workaround to simulate
drag and drop. You can see a full write-up along with example code here: http://elementalselenium.com/tips/39-drag-and-drop


Cheers,
Dave H
@TourDeDave

Reported by dave@arrgyle.com on 2014-02-26 17:07:27

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I've created a more versatile HTML5 Drag and Drop simulator. It uses native JavaScript
and not jQuery. It allows for Cross-Window drag and drop (example provided in file)
and dragging to a specific position. The attached file is written for Java WebDiver,
but could easily be converted, and has been tested on Firefox 24 and Firefox 17 on
RHEL 6.4, Windows 7, and Mac.

Reported by salomj9 on 2014-07-30 16:47:54


- _Attachment: [HTML5DragAndDropSimulator.txt](https://storage.googleapis.com/google-code-attachments/selenium/issue-6315/comment-5/HTML5DragAndDropSimulator.txt)_

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

@Dave: I tried your code on w3schools and it doesn't work? http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop

I think it depends on how the draggable elements are created maybe, your link has extremely
simple divs

@salo....@gmail.com: Do we have to provide Position of from and to in the function
? Is there a way for the code to figure that out and input arguments are only "from"
and "to" html locators please?

Thanks much!

Reported by seleniumfrmwrk on 2015-01-08 03:13:59

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

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

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant