Celerity and drag testing

300 views
Skip to first unread message

Rodrigo Rosenfeld Rosas

unread,
Dec 16, 2009, 8:07:45 PM12/16/09
to Capybara
Hi, I'm stuck in a problem and would be grateful if someone could help
me...

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
behavior.

While debugging the test, I discovered that the elements were found
correctly but, although dragging raises no errors, it still doesn't
work.

I've tried both following approaches:

- drag(source_xpath, target_xpath)

and the one inspired by the spec that comes with Capybara:

- page.driver.find(source_xpath).first.drag_to(page.driver.find
(target_xpath).first)

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
in HtmlUnit?

Thanks in advance,

Rodrigo.

Rodrigo Rosenfeld Rosas

unread,
Dec 17, 2009, 7:19:40 AM12/17/09
to Capybara
Changing the driver to Selenium also does not work. Same happens (at
least it is consistent).

But using "dragAndDropToObject" from Selenium IDE passing the same
locators works as expected...

Any hints?

Rob Holland

unread,
Dec 17, 2009, 7:43:05 AM12/17/09
to ruby-c...@googlegroups.com

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.

Rodrigo Rosenfeld Rosas

unread,
Dec 20, 2009, 8:06:26 AM12/20/09
to ruby-c...@googlegroups.com
Rob Holland escreveu:

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:

http://dev.emprelab.com.br/simulations/1

User: test
Password: password

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... :(

Best Regards,

Rodrigo.

Rodrigo Rosenfeld Rosas

unread,
Dec 20, 2009, 9:04:51 AM12/20/09
to Capybara

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?

Rodrigo.

Reply all
Reply to author
Forward
0 new messages