I'm using Capybara with Culerity driver (although I am not using
Cucumber) for testing an application written with jQuery.
Application works as intended but I am not able to test the drag
While debugging the test, I discovered that the elements were found
correctly but, although dragging raises no errors, it still doesn't
I've tried both following approaches:
- drag(source_xpath, target_xpath)
and the one inspired by the spec that comes with Capybara:
None raises an exception.
Any hints why the drag is not working?
Both xpath are correct as I checked with a debugger.
How can I debug this kind of behavior since I can't see mouse moving
Thanks in advance,
But using "dragAndDropToObject" from Selenium IDE passing the same
locators works as expected...
I've also had issues, but couldn't see the difference between my code
(which fails) and the (passing) drag and drop spec.
If you can figure out what the difference is between your code and the
passing spec/and or write a failing spec, I can fix this up.
Hi Rob, sorry for the delay in answering, but my time to develop this
project is limited and I was trying to figure out what the problem was.
It turns out that both drag_and_drop and drag_and_drop_to_object from
selenium-client work. It seems like a problem with selenium-webdriver
ruby client instead of Capybara itself.
It seems that webdriver ruby client does not implement dragAndDropOn
yet, but uses its own dragElement instead which calls dragAndDropBy to
achieve the same goal.
I would bet that the mouse events are not being sent to the middle of
the element, but in some of its edges instead, and this could result in
dragging working sometimes and not working other times...
Selenium states that the drag mouse events use the element central point
and maybe it is way it works with Selenium...
But it seems that webdriver implementation is a bit complicate with all
that bridges not well documented and I ended up not digging it too much...
My inspiration has just gone since I broke a tooth with a candy an hour
ago, so I am not able to concentrate myself...
If someone feels inspired and is interested enough in the drag problem,
here is a link to test on:
Feel free to do what you want to debug the problem. This site is aimed
to test only and has no real data.
Dragging is working if you can move a person to another row.
I have no idea in how to debug this in a headless browser such as
HtmlUnit, for instance...
Let me keep trying to contact my dentist... :(
Investigating a bit more, while my dentist insist in not answering, I
found that original Java-implementation of webdriver is broken too. I
used JRuby console (jirb) for testing the Java implementation directly
and both dragAndDropOn and dragAndDropBy don't work on my tests using
FirefoxDriver... findElement is working correctly though, using
By.xpath(locator), since text() returns the inner text correctly.
I'm using Debian sid amd64 with Iceweasel 3.5.6.
Does this information help?