Skip to content

Commit 64a04f8

Browse files
committed
[py] offsets for moving to an element will originate from in-view center point
1 parent d09259a commit 64a04f8

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

py/selenium/webdriver/common/actions/pointer_actions.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,7 @@ def move_to(self, element, x=0, y=0, width=None, height=None, pressure=None,
5656
if not isinstance(element, WebElement):
5757
raise AttributeError("move_to requires a WebElement")
5858

59-
if x or y:
60-
warnings.warn(
61-
"move_to_element_with_offset() currently tries to use the top left corner "
62-
"of the element as the origin; in Selenium 4.3 it will use the in-view "
63-
"center point of the element as the origin.",
64-
DeprecationWarning,
65-
stacklevel=2
66-
)
67-
el_rect = element.rect
68-
left_offset = el_rect['width'] / 2
69-
top_offset = el_rect['height'] / 2
70-
left = -left_offset + (x or 0)
71-
top = -top_offset + (y or 0)
72-
else:
73-
left = 0
74-
top = 0
75-
76-
self.source.create_pointer_move(origin=element, duration=self._duration, x=int(left), y=int(top),
59+
self.source.create_pointer_move(origin=element, duration=self._duration, x=int(x), y=int(y),
7760
width=width, height=height, pressure=pressure,
7861
tangential_pressure=tangential_pressure,
7962
tilt_x=tilt_x, tilt_y=tilt_y, twist=twist,

py/test/selenium/webdriver/common/w3c_interaction_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ def test_pen_pointer_properties(driver, pages):
188188
center = _get_inview_center(pointerArea.rect, _get_viewport_rect(driver))
189189
actions.pointer_action.move_to(pointerArea) \
190190
.pointer_down(pressure=0.36, tilt_x=-72, tilt_y=9, twist=86) \
191-
.move_to(pointerArea, x=10, y=40) \
191+
.move_to(pointerArea, x=5, y=10) \
192192
.pointer_up() \
193-
.move_to(pointerArea, x=10, y=50)
193+
.move_to(pointerArea, x=5, y=10)
194194
actions.perform()
195195
events = _get_events(driver)
196196
assert events[3]["type"] == "pointerdown"
@@ -225,11 +225,11 @@ def test_touch_pointer_properties(driver, pages):
225225
center = _get_inview_center(pointerArea.rect, _get_viewport_rect(driver))
226226
touch_input = PointerInput(interaction.POINTER_TOUCH, "touch")
227227
touch_chain = ActionBuilder(driver, mouse=touch_input)
228-
touch_chain.pointer_action.move_to(pointerArea, x=50, y=25) \
228+
touch_chain.pointer_action.move_to(pointerArea) \
229229
.pointer_down(width=23, height=31, pressure=0.78, tilt_x=21, tilt_y=-8, twist=355) \
230-
.move_to(pointerArea, x=60, y=35, width=39, height=35, pressure=0.91, tilt_x=-19, tilt_y=62, twist=345) \
230+
.move_to(pointerArea, x=10, y=10, width=39, height=35, pressure=0.91, tilt_x=-19, tilt_y=62, twist=345) \
231231
.pointer_up() \
232-
.move_to(pointerArea, x=80, y=50)
232+
.move_to(pointerArea, x=15, y=15)
233233
touch_chain.perform()
234234
events = _get_events(driver)
235235
assert len(events) == 7

0 commit comments

Comments
 (0)