Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created July 23, 2016 23:07
Show Gist options
  • Save twalpole/64c090941bfba5d5e35843a180460bba to your computer and use it in GitHub Desktop.
Save twalpole/64c090941bfba5d5e35843a180460bba to your computer and use it in GitHub Desktop.
TableDnD Poltergeist
require "capybara/poltergeist"
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:poltergeist, app)
sess.visit("/")
puts "drag table text is #{sess.find(:css, '#drag_table').text}"
sess.find(:css, '#row1 td.handle').drag_to(sess.find(:css,'#row3'))
puts "drag table text is now #{sess.find(:css, '#drag_table').text}"
__END__
<!doctype html>
<html>
<head>
<title>Some title</title>
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://raw.githubusercontent.com/isocra/TableDnD/master/js/jquery.tablednd.js"></script
</head>
<body>
<table id="drag_table" data-table="dnd" data-draghandle="td.handle">
<tbody>
<tr id="row1"><td>Some info</td><td class="handle">Row 1</td></tr>
<tr id="row2"><td>Some info</td><td class="handle">Row 2</td></tr>
<tr id="row3"><td>Some info</td><td class="handle">Row 3</td></tr>
<tr id="row4"><td>Some info</td><td class="handle">Row 4</td></tr>
<tr id="row5"><td>Some info</td><td class="handle">Row 5</td></tr>
</tbody>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment