diff --git a/lib/capybara/cuprite/browser.rb b/lib/capybara/cuprite/browser.rb index 3d5045b..162cbb8 100644 --- a/lib/capybara/cuprite/browser.rb +++ b/lib/capybara/cuprite/browser.rb @@ -139,23 +139,25 @@ def source raise NotImplementedError end - def drag(node, other, steps) + def drag(node, other, steps, delay = nil) x1, y1 = node.find_position x2, y2 = other.find_position mouse.move(x: x1, y: y1) mouse.down + sleep delay if delay mouse.move(x: x2, y: y2, steps: steps) mouse.up end - def drag_by(node, x, y, steps) + def drag_by(node, x, y, steps, delay = nil) x1, y1 = node.find_position x2 = x1 + x y2 = y1 + y mouse.move(x: x1, y: y1) mouse.down + sleep delay if delay mouse.move(x: x2, y: y2, steps: steps) mouse.up end diff --git a/lib/capybara/cuprite/node.rb b/lib/capybara/cuprite/node.rb index 3efab57..54a0708 100644 --- a/lib/capybara/cuprite/node.rb +++ b/lib/capybara/cuprite/node.rb @@ -162,13 +162,13 @@ def hover def drag_to(other, **options) options[:steps] ||= 1 - command(:drag, other.node, options[:steps]) + command(:drag, other.node, options[:steps], options[:delay]) end def drag_by(x, y, **options) options[:steps] ||= 1 - command(:drag_by, x, y, options[:steps]) + command(:drag_by, x, y, options[:steps], options[:delay]) end def trigger(event)