Skip to content

Commit eb602e3

Browse files
authored
Merge pull request #176 from botandrose/drag_and_drop
implement Browser#drag and #drag_by.
2 parents 5e06d87 + ad1c3d7 commit eb602e3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

lib/capybara/cuprite/browser.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,23 @@ def source
113113
end
114114

115115
def drag(node, other)
116-
raise NotImplementedError
116+
x1, y1 = node.find_position
117+
x2, y2 = other.find_position
118+
119+
mouse.move(x: x1, y: y1)
120+
mouse.down
121+
mouse.move(x: x2, y: y2)
122+
mouse.up
117123
end
118124

119125
def drag_by(node, x, y)
120-
raise NotImplementedError
126+
x1, y1 = node.find_position
127+
x2, y2 = x1 + x, y1 + y
128+
129+
mouse.move(x: x1, y: y1)
130+
mouse.down
131+
mouse.move(x: x2, y: y2)
132+
mouse.up
121133
end
122134

123135
def select_file(node, value)

lib/capybara/cuprite/node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def hover
160160
end
161161

162162
def drag_to(other)
163-
command(:drag, other)
163+
command(:drag, other.node)
164164
end
165165

166166
def drag_by(x, y)

spec/features/session_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575
end
576576
end
577577

578-
context "dragging support", skip: true do
578+
context "dragging support" do
579579
before do
580580
@session.visit "/cuprite/drag"
581581
end

0 commit comments

Comments
 (0)