jonleighton/poltergeist — pull request #247 by olly (2013-01-30 10:37:07+00:00)
Title: Drag & Drop a Node by Pixels

I've added an implementation to allow dragging of elements by pixel amounts. The impetus behind this was switching an application from Selenium to Poltergeist and it had a [custom extension](http://stackoverflow.com/a/10868865/818057) for doing this in Selenium.

I've implemented a similar API for Poltergeist, using this application extension:

module CapybaraExtension
def drag_by(dimensions)
base.drag_by(dimensions)
end
end

::Capybara::Node::Element.send(:include, CapybaraExtension)

the API looks like this:

find('.ui-slider-handle').drag_by(left: 100)

It supports the following options: `:up`, `:down`, `:left`, `:down`.

---

Is this something you would consider adding to Poltergeist? If you did I think a patch to Capybara would probably get accepted because it can currently be implemented in Selenium.

Have you got any comments on the API? I don't think `drag_by` is a great name, I think `drag` would be better name. What do you think about overloading the current method?

---

I've tested this branch on an application and it works. I haven't included any specs yet. I assume these would belong in `session_spec.rb`. Also what is the policy on documentation?