We are testing a simple drag and drop behaviour with Intern and the excellent new Leadfoot client library. Our requirement is simple:
- Find an element and move to it
- Press the mouse button (pick up the draggable item)
- Find another element and move to it (drag)
- Release the mouse button (drop the draggable item)
- Check something happened
I would expect the following example syntax to perform this task:
.findById("MY_DRAGGABLE")
.moveMouseTo()
.pressMouseButton()
.end()
.findById("MY_DROP_ZONE")
.moveMouseTo()
.releaseMouseButton()
.end()
This doesn't work. I already know that there may be an idiosyncrasy in Selenium and that a couple of 'moves' may be required to pick up something draggable:
.findById("MY_DRAGGABLE")
.moveMouseTo()
.pressMouseButton()
.moveMouseTo(null, 1, 1)
.end()
This still doesn't work and in fact to make the 'pickup' work I have to add a click() as well:
.findById("MY_DRAGGABLE")
.moveMouseTo()
.click()
.pressMouseButton()
.moveMouseTo(null, 1, 1)
.end()
This part now works and the draggable is picked up, but the move and release doesn't work. In fact to make them do what I want I have to use a rather strange syntax which breaks out of the promise chain:
.findById("MY_DROP_ZONE")
.then(function(element) {
browser.moveMouseTo(element)
})
.releaseMouseButton()
.end()
So in the end I have:
.findById("MY_DRAGGABLE")
.moveMouseTo()
.click()
.pressMouseButton()
.moveMouseTo(null, 1, 1)
.end()
.findById("MY_DROP_ZONE")
.then(function(element) {
browser.moveMouseTo(element)
})
.releaseMouseButton()
.end()
What I'm interested to know is whether or not there is something about object positioning that I'm missing here or whether or not there may be a fault in the commands we are using?
We're testing this on Firefox primarily on a variety of platforms.