0

Below is the code I am using, it will access one public website which is written using Html5,the code is trying to drag the "One" to trashbin, but it doesn't do anything. Is there any workaround to make it work? Thanks in advance!

    FirefoxProfile profile = new FirefoxProfile();
    profile.setEnableNativeEvents(true);
    WebDriver driver = new FirefoxDriver(profile);
    driver.get("http://html5demos.com/drag");

    WebElement draggable = driver.findElement(By.id("one"));
    WebElement droppable = driver.findElement(By.id("bin"));

    new Actions(driver).dragAndDrop(draggable, droppable).build().perform();

Additional information is:

Selenium version: 2.25.0 OS: Mac OS Lion Browser: Firefox Browser version: 10.0.2 and 14.0.1

Jingjing
  • 13
  • 1
  • 5
  • We are seeing the exact same issue as posted by Jingjing. Is there an open bug with Selenium for this. This same code works just fine with InternetExplorerDriver, but does not work with Firefox driver. – Rolandas Burbulis Nov 05 '12 at 21:05
  • I had the same problem. After extensive research on SO and the net, I think this is a Selenium bug. I filed a bug report here: https://code.google.com/p/selenium/issues/detail?id=6315&thanks=6315&ts=1380031813 – Michael Herrmann Sep 24 '13 at 14:19
  • possible duplicate of [How to simulate HTML5 Drag and Drop in Selenium Webdriver](http://stackoverflow.com/questions/29381233/how-to-simulate-html5-drag-and-drop-in-selenium-webdriver-in-python) – alecxe Sep 04 '15 at 14:05

1 Answers1

0

I would risk saying it is some sort of compatibility issue. I used the following code on http://jqueryui.com/demos/draggable/

System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://jqueryui.com/demos/draggable/");
WebElement draggable = driver.findElement(By.id("draggable"));
new Actions(driver).dragAndDropBy(draggable, 200, 10).build().perform();

and it worked like a charm on the IE9. However it did not work with my Firefox 14 which may be to "new".

You can also try some workaround using JavaScriptExecutor, sth like this is described here: HTML5 Drag and Drop using Selenium Webdriver for Ruby

Community
  • 1
  • 1
Arek
  • 1,941
  • 4
  • 22
  • 27