Skip to content

Commit 2580fc6

Browse files
committed
[py]: Simplify logic for ActionsBuilder initialiser
1 parent 9c4eb36 commit 2580fc6

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

py/selenium/webdriver/common/actions/action_builder.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,16 @@ def __init__(
3939
keyboard: Optional[KeyInput] = None,
4040
duration: int = 250,
4141
) -> None:
42-
if not mouse:
43-
mouse = PointerInput(interaction.POINTER_MOUSE, "mouse")
44-
if not keyboard:
45-
keyboard = KeyInput(interaction.KEY)
46-
if not wheel:
47-
wheel = WheelInput(interaction.WHEEL)
42+
mouse = mouse or PointerInput(interaction.POINTER_MOUSE, "mouse")
43+
keyboard = keyboard or KeyInput(interaction.KEY)
44+
wheel = wheel or WheelInput(interaction.WHEEL)
4845
self.devices = [mouse, keyboard, wheel]
4946
self._key_action = KeyActions(keyboard)
5047
self._pointer_action = PointerActions(mouse, duration=duration)
5148
self._wheel_action = WheelActions(wheel)
5249
self.driver = driver
5350

54-
def get_device_with(self, name: str) -> Union["WheelInput", "PointerInput", "KeyInput"]:
51+
def get_device_with(self, name: str) -> Optional[Union["WheelInput", "PointerInput", "KeyInput"]]:
5552
return next(filter(lambda x: x == name, self.devices), None)
5653

5754
@property

0 commit comments

Comments
 (0)