From 1ee594aaf8e2dfe3730973f17c8f6e80926d0828 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Tue, 3 Jun 2025 22:20:57 -0700 Subject: [PATCH 1/7] fixed mypy error and change source var --- py/selenium/webdriver/common/actions/key_actions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 1c1278e6ba5d5..3ec141e4cb518 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -27,8 +27,8 @@ class KeyActions(Interaction): def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -> None: if source is None: source = KeyInput(KEY) - self.source = source - super().__init__(source) + self.input_source = source + super().__init__(KEY) def key_down(self, letter: str) -> KeyActions: return self._key_action("create_key_down", letter) @@ -48,6 +48,6 @@ def send_keys(self, text: str | list) -> KeyActions: return self def _key_action(self, action: str, letter) -> KeyActions: - meth = getattr(self.source, action) + meth = getattr(self.input_source, action) meth(letter) return self From 2fb4fe124a7dd026467b0b2e10363c8de0491fa9 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Tue, 3 Jun 2025 23:01:44 -0700 Subject: [PATCH 2/7] fixed an error --- py/selenium/webdriver/common/actions/key_actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 3ec141e4cb518..fe524f905a4bb 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -28,7 +28,7 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - if source is None: source = KeyInput(KEY) self.input_source = source - super().__init__(KEY) + super().__init__(self.input_source) def key_down(self, letter: str) -> KeyActions: return self._key_action("create_key_down", letter) From dc3346bf91d60e9fa109cfec43827ca0727f05b5 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Tue, 3 Jun 2025 23:08:55 -0700 Subject: [PATCH 3/7] fixed an error --- py/selenium/webdriver/common/actions/key_actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index fe524f905a4bb..3ec141e4cb518 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -28,7 +28,7 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - if source is None: source = KeyInput(KEY) self.input_source = source - super().__init__(self.input_source) + super().__init__(KEY) def key_down(self, letter: str) -> KeyActions: return self._key_action("create_key_down", letter) From dfc39b5f749d638cfeed3e527f22d3563fe2a401 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Tue, 3 Jun 2025 23:55:38 -0700 Subject: [PATCH 4/7] fixed error for source type --- .../webdriver/common/actions/key_actions.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 3ec141e4cb518..6f0cb26cf5dce 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -17,7 +17,7 @@ from __future__ import annotations from ..utils import keys_to_typing -from .interaction import KEY, Interaction +from .interaction import KEY, POINTER, WHEEL, Interaction from .key_input import KeyInput from .pointer_input import PointerInput from .wheel_input import WheelInput @@ -28,7 +28,19 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - if source is None: source = KeyInput(KEY) self.input_source = source - super().__init__(KEY) + + # Determine the correct source type string based on the input object + if isinstance(source, KeyInput): + source_type = KEY + elif isinstance(source, PointerInput): + source_type = POINTER + elif isinstance(source, WheelInput): + source_type = WHEEL + else: + source_type = KEY # fallback + + super().__init__(source_type) + def key_down(self, letter: str) -> KeyActions: return self._key_action("create_key_down", letter) From 82a4897ba0a3f10d8b5b69a5af2cafe810d4773e Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Wed, 4 Jun 2025 04:45:22 -0700 Subject: [PATCH 5/7] fixed keyaction error --- py/selenium/webdriver/common/actions/key_actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 6f0cb26cf5dce..35b11e3e53d9e 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -43,13 +43,13 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - def key_down(self, letter: str) -> KeyActions: - return self._key_action("create_key_down", letter) + return self.keyaction("create_key_down", letter) def key_up(self, letter: str) -> KeyActions: - return self._key_action("create_key_up", letter) + return self.keyaction("create_key_up", letter) def pause(self, duration: int = 0) -> KeyActions: - return self._key_action("create_pause", duration) + return self.keyaction("create_pause", duration) def send_keys(self, text: str | list) -> KeyActions: if not isinstance(text, list): @@ -59,7 +59,7 @@ def send_keys(self, text: str | list) -> KeyActions: self.key_up(letter) return self - def _key_action(self, action: str, letter) -> KeyActions: + def keyaction(self, action: str, letter) -> KeyActions: meth = getattr(self.input_source, action) meth(letter) return self From d706400f8cc173f9ac9d5314919a5e4d659b72d8 Mon Sep 17 00:00:00 2001 From: pallavigotwork Date: Wed, 4 Jun 2025 09:40:11 -0700 Subject: [PATCH 6/7] fixed error --- .../webdriver/common/actions/key_actions.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 35b11e3e53d9e..8bf9e275bd454 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + from __future__ import annotations from ..utils import keys_to_typing @@ -27,7 +28,7 @@ class KeyActions(Interaction): def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -> None: if source is None: source = KeyInput(KEY) - self.input_source = source + self.input_source = source # Store the actual input object # Determine the correct source type string based on the input object if isinstance(source, KeyInput): @@ -38,18 +39,17 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - source_type = WHEEL else: source_type = KEY # fallback - - super().__init__(source_type) - + + super().__init__(source_type) # Pass string to parent def key_down(self, letter: str) -> KeyActions: - return self.keyaction("create_key_down", letter) + return self._key_action("create_key_down", letter) def key_up(self, letter: str) -> KeyActions: - return self.keyaction("create_key_up", letter) + return self._key_action("create_key_up", letter) def pause(self, duration: int = 0) -> KeyActions: - return self.keyaction("create_pause", duration) + return self._key_action("create_pause", duration) def send_keys(self, text: str | list) -> KeyActions: if not isinstance(text, list): @@ -59,7 +59,7 @@ def send_keys(self, text: str | list) -> KeyActions: self.key_up(letter) return self - def keyaction(self, action: str, letter) -> KeyActions: - meth = getattr(self.input_source, action) + def _key_action(self, action: str, letter) -> KeyActions: + meth = getattr(self.input_source, action) # Use input_source, not source meth(letter) return self From 4080d292b7f27d704dadd220ffca8a253e247c28 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Fri, 6 Jun 2025 08:33:40 -0400 Subject: [PATCH 7/7] Remove comments --- py/selenium/webdriver/common/actions/key_actions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/py/selenium/webdriver/common/actions/key_actions.py b/py/selenium/webdriver/common/actions/key_actions.py index 8bf9e275bd454..b5052fe5b188e 100644 --- a/py/selenium/webdriver/common/actions/key_actions.py +++ b/py/selenium/webdriver/common/actions/key_actions.py @@ -28,7 +28,7 @@ class KeyActions(Interaction): def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -> None: if source is None: source = KeyInput(KEY) - self.input_source = source # Store the actual input object + self.input_source = source # Determine the correct source type string based on the input object if isinstance(source, KeyInput): @@ -38,9 +38,9 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) - elif isinstance(source, WheelInput): source_type = WHEEL else: - source_type = KEY # fallback + source_type = KEY - super().__init__(source_type) # Pass string to parent + super().__init__(source_type) def key_down(self, letter: str) -> KeyActions: return self._key_action("create_key_down", letter) @@ -60,6 +60,6 @@ def send_keys(self, text: str | list) -> KeyActions: return self def _key_action(self, action: str, letter) -> KeyActions: - meth = getattr(self.input_source, action) # Use input_source, not source + meth = getattr(self.input_source, action) meth(letter) return self