Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I drag and drop using poltergeist?

Right now I'm using the selenium driver with Capybara, but I'd like to switch to using Poltergeist. A lot of the interface I'm testing, though, involves dragging and dropping elements in particular locations on the page. I've written the following method for dragging and dropping, which works in selenium:

def drag_drop(page, draggable, droppable, xoffset, yoffset)
  driver = page.driver.browser
  driver.mouse.move_to(draggable.native, draggable.native.size.height / 2, draggable.native.size.width / 2)
  driver.mouse.down
  driver.mouse.move_to(droppable.native, droppable.native.size.height / 2 + yoffset, droppable.native.size.width / 2 + xoffset)
  driver.mouse.up
end

How would I go about writing something like this in poltergeist?

like image 201
lobati Avatar asked May 01 '13 05:05

lobati


1 Answers

I don't know if it's exactly what you're looking for, but Capybara has an API for dragging which Poltergeist supports.

like image 119
jonleighton Avatar answered Oct 24 '22 15:10

jonleighton