From 190a8fba8fb5c177e39efa2fd1b7cd4dd36fde6b Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 27 May 2022 00:19:18 -0500 Subject: [PATCH] [py] warn about upcoming changes to move_to_element_with_offset behavior --- py/selenium/webdriver/common/actions/mouse_button.py | 3 +++ py/selenium/webdriver/common/actions/pointer_actions.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/py/selenium/webdriver/common/actions/mouse_button.py b/py/selenium/webdriver/common/actions/mouse_button.py index c187c37f1ce5b..b0fa713312e38 100644 --- a/py/selenium/webdriver/common/actions/mouse_button.py +++ b/py/selenium/webdriver/common/actions/mouse_button.py @@ -21,3 +21,6 @@ class MouseButton: LEFT = 0 MIDDLE = 1 RIGHT = 2 + BACK = 3 + FORWARD = 4 + diff --git a/py/selenium/webdriver/common/actions/pointer_actions.py b/py/selenium/webdriver/common/actions/pointer_actions.py index 8372c71b6a499..36572ef148db5 100644 --- a/py/selenium/webdriver/common/actions/pointer_actions.py +++ b/py/selenium/webdriver/common/actions/pointer_actions.py @@ -14,6 +14,8 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +import warnings + from . import interaction from .interaction import Interaction @@ -57,6 +59,13 @@ def move_to(self, element, x=0, y=0, width=None, height=None, pressure=None, raise AttributeError("move_to requires a WebElement") if x or y: + warnings.warn( + "move_to_element_with_offset() currently tries to use the top left corner " + "of the element as the origin; in Selenium 4.3 it will use the in-view " + "center point of the element as the origin.", + DeprecationWarning, + stacklevel=2 + ) el_rect = element.rect left_offset = el_rect['width'] / 2 top_offset = el_rect['height'] / 2