Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions py/selenium/webdriver/common/actions/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
# under the License.
from typing import Union

from .input_device import InputDevice

KEY = "key"
POINTER = "pointer"
NONE = "none"
WHEEL = "wheel"
SOURCE_TYPES = {KEY, POINTER, NONE}
SOURCE_TYPES = {KEY, POINTER, WHEEL, NONE}

POINTER_MOUSE = "mouse"
POINTER_TOUCH = "touch"
Expand All @@ -32,7 +34,7 @@
class Interaction:
PAUSE = "pause"

def __init__(self, source: str) -> None:
def __init__(self, source: InputDevice) -> None:
self.source = source


Expand Down
17 changes: 3 additions & 14 deletions py/selenium/webdriver/common/actions/key_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

from ..utils import keys_to_typing
from .interaction import KEY, POINTER, WHEEL, Interaction
from .interaction import KEY, Interaction
from .key_input import KeyInput
from .pointer_input import PointerInput
from .wheel_input import WheelInput
Expand All @@ -29,18 +29,7 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -
if source is None:
source = KeyInput(KEY)
self.input_source = source

# 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

super().__init__(source_type)
super().__init__(source)

def key_down(self, letter: str) -> KeyActions:
return self._key_action("create_key_down", letter)
Expand All @@ -60,6 +49,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)
meth = getattr(self.source, action)
meth(letter)
return self
4 changes: 2 additions & 2 deletions py/selenium/webdriver/common/actions/wheel_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

from typing import Optional

from .interaction import Interaction
from .interaction import WHEEL, Interaction
from .wheel_input import WheelInput


class WheelActions(Interaction):
def __init__(self, source: Optional[WheelInput] = None):
if source is None:
source = WheelInput("wheel")
source = WheelInput(WHEEL)
super().__init__(source)

def pause(self, duration: float = 0):
Expand Down