Skip to content

Commit 523fbc8

Browse files
[py] Fixed mypy error and change source var (#15853)
Co-authored-by: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com>
1 parent f86a747 commit 523fbc8

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

py/selenium/webdriver/common/actions/key_actions.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
from __future__ import annotations
1819

1920
from ..utils import keys_to_typing
20-
from .interaction import KEY, Interaction
21+
from .interaction import KEY, POINTER, WHEEL, Interaction
2122
from .key_input import KeyInput
2223
from .pointer_input import PointerInput
2324
from .wheel_input import WheelInput
@@ -27,8 +28,19 @@ class KeyActions(Interaction):
2728
def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -> None:
2829
if source is None:
2930
source = KeyInput(KEY)
30-
self.source = source
31-
super().__init__(source)
31+
self.input_source = source
32+
33+
# Determine the correct source type string based on the input object
34+
if isinstance(source, KeyInput):
35+
source_type = KEY
36+
elif isinstance(source, PointerInput):
37+
source_type = POINTER
38+
elif isinstance(source, WheelInput):
39+
source_type = WHEEL
40+
else:
41+
source_type = KEY
42+
43+
super().__init__(source_type)
3244

3345
def key_down(self, letter: str) -> KeyActions:
3446
return self._key_action("create_key_down", letter)
@@ -48,6 +60,6 @@ def send_keys(self, text: str | list) -> KeyActions:
4860
return self
4961

5062
def _key_action(self, action: str, letter) -> KeyActions:
51-
meth = getattr(self.source, action)
63+
meth = getattr(self.input_source, action)
5264
meth(letter)
5365
return self

0 commit comments

Comments
 (0)