Skip to content

Commit be70262

Browse files
committed
[rb] warn about upcoming changes to #move_to
1 parent 9990fba commit be70262

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

‎rb/.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Metrics/MethodLength:
7777

7878
Metrics/ModuleLength:
7979
CountComments: false
80-
Max: 101
80+
Max: 110
8181
Exclude:
8282
- 'lib/selenium/webdriver/common/platform.rb'
8383
- 'spec/**/*'

‎rb/lib/selenium/webdriver/common/action_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def pause(deprecated_device = nil, deprecated_duration = nil, device: nil, durat
198198
deprecate_method(deprecated_device, deprecated_duration)
199199

200200
device ||= deprecated_device || pointer_input
201-
device.create_pause(duration || deprecated_duration)
201+
device.create_pause(deprecated_duration || duration)
202202
self
203203
end
204204

‎rb/lib/selenium/webdriver/common/interactions/pointer_actions.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def pointer_up(button = :left, device: nil, **opts)
9999
def move_to(element, right_by = nil, down_by = nil, device: nil, duration: default_move_duration, **opts)
100100
pointer = pointer_input(device)
101101
if right_by || down_by
102+
WebDriver.logger.warn("moving to an element with offset currently tries to use
103+
the top left corner of the element as the origin; in Selenium 4.3 it will use the in-view
104+
center point of the element as the origin.")
102105
size = element.size
103106
left_offset = (size[:width] / 2).to_i
104107
top_offset = (size[:height] / 2).to_i
@@ -134,12 +137,13 @@ def move_to(element, right_by = nil, down_by = nil, device: nil, duration: defau
134137
# @raise [MoveTargetOutOfBoundsError] if the provided offset is outside the document's boundaries.
135138
#
136139

137-
def move_by(right_by, down_by, device: nil, duration: default_move_duration)
140+
def move_by(right_by, down_by, device: nil, duration: default_move_duration, **opts)
138141
pointer = pointer_input(device)
139142
pointer.create_pointer_move(duration: duration,
140143
x: Integer(right_by),
141144
y: Integer(down_by),
142-
origin: Interactions::PointerMove::POINTER)
145+
origin: Interactions::PointerMove::POINTER,
146+
**opts)
143147
tick(pointer)
144148
self
145149
end
@@ -161,12 +165,13 @@ def move_by(right_by, down_by, device: nil, duration: default_move_duration)
161165
# @raise [MoveTargetOutOfBoundsError] if the provided x or y value is outside the document's boundaries.
162166
#
163167

164-
def move_to_location(x, y, device: nil, duration: default_move_duration)
168+
def move_to_location(x, y, device: nil, duration: default_move_duration, **opts)
165169
pointer = pointer_input(device)
166170
pointer.create_pointer_move(duration: duration,
167171
x: Integer(x),
168172
y: Integer(y),
169-
origin: Interactions::PointerMove::VIEWPORT)
173+
origin: Interactions::PointerMove::VIEWPORT,
174+
**opts)
170175
tick(pointer)
171176
self
172177
end

‎rb/lib/selenium/webdriver/common/interactions/pointer_press.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class PointerPress < Interaction
3838
x1: 3,
3939
back: 3,
4040
x2: 4,
41-
forward: 4,
42-
erase: 5}.freeze
41+
forward: 4}.freeze
4342
DIRECTIONS = {down: :pointerDown, up: :pointerUp}.freeze
4443

4544
def initialize(source, direction, button, **opts)

‎rb/spec/integration/selenium/webdriver/action_builder_spec.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ module WebDriver
271271
pointer_options = {pressure: 0.8, tilt_x: -40, tilt_y: -10, twist: 177}
272272
actions = driver.action(devices: :pen)
273273
.move_by(x_val + 5, y_val + 5)
274-
.pointer_down(**pointer_options)
275-
.move_by(2, 2, duration: 0.8)
274+
.pointer_down
275+
.move_by(2, 2, duration: 0.8, **pointer_options)
276276
.pointer_up
277277

278278
start = Time.now
@@ -288,15 +288,13 @@ module WebDriver
288288
expect(move_to).to include("button" => "-1",
289289
"pageX" => (x_val + 5).to_s,
290290
"pageY" => (y_val + 5).floor.to_s)
291-
expect(down).to include("button" => "0",
292-
"pageX" => (x_val + 5).to_s,
293-
"pageY" => (y_val + 5).floor.to_s,
294-
"tiltX" => "-40",
295-
"tiltY" => "-10",
296-
"twist" => "177")
291+
expect(down).to include("button" => "0")
297292
expect(move_by).to include("button" => "-1",
298293
"pageX" => (x_val + 5 + 2).to_s,
299-
"pageY" => (y_val + 5 + 2).floor.to_s)
294+
"pageY" => (y_val + 5 + 2).floor.to_s,
295+
"tiltX" => "-40",
296+
"tiltY" => "-10",
297+
"twist" => "177")
300298
expect(up).to include("button" => "0",
301299
"pageX" => (x_val + 5 + 2).to_s,
302300
"pageY" => (y_val + 5 + 2).floor.to_s)

0 commit comments

Comments
 (0)