We have a sortable list using JQuery UI Sortable that we are trying to automate using Selenium.
It looks like the dragAndDrop function should work, but when we call it, the UI does not change. However if we look at the DOM with firebug, we see that the order of the list elements DID change. It seems it's just the UI that does not refresh.
Any idea how to get it working?
Try dragAndDropToObject. I was just able to move things around using Se-IDE (though I suspect Se-RC would work as well).
dragAndDropToObject | css=div[class=demo] > ul > li:nth(2) | css=div[class=demo] > ul > li:nth(5)
No solution we could find worked, so we simply created helper javascript functions that moved the html elements around using jQuery. It worked for our case but it feels dirty!
Here's what I have found works well with Selenium and Capybara
I have developed a JQuery plugin to solve this problem, check out jquery.simulate.drag-sortable.js which includes a plugin along with a suite of tests.
Hope you find this useful! Feedback is welcome.
Matt
Here in 2017 rails 4+ angular 1x, using capybara selenium testing with 2 different drivers: poltergeist and chrome, I was able to get the capybara built-in
drag_to
to work out of the box. I won't say that it's 100% reliable as to where it drags stuff, but the stuff dragged and stayed dragged so that was a pleasant surprise. I also got a modified version of Julie's answer to work in chrome, but not poltergeist (nodriver.browser.action
... not sure what the poltergeist version is if one even exists).So anyway something like:
I was surprised that it worked so easily given the above comments but I guess things have improved.