Skip to content

Instantly share code, notes, and snippets.

@rjurado01
Created May 15, 2016 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurado01/975e9116fde531483cd57c3d5e9a11c1 to your computer and use it in GitHub Desktop.
Save rjurado01/975e9116fde531483cd57c3d5e9a11c1 to your computer and use it in GitHub Desktop.
# test drag and drop of jquery-ui-sortable with capybara
# based on: http://heywill.com/blog/2012/12/15/using-capybara-to-drag-a-jquery-ui-sortable-onto-a-jquery-ui-droppable
offset = page.evaluate_script("$('#sortable').offset()")
top = offset['top'] + 20
left = offset['left']
page.execute_script("$('body').append('<div id=\"test\" style=\"position: fixed; top: #{top}px; left: #{left}px; width: 10px; height: 10px;\"></div>');")
element = page.find("#item_#{item.id}")
test_element = page.find('#test')
element.drag_to(test_element)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment