Skip to content
Merged
11 changes: 6 additions & 5 deletions py/selenium/webdriver/common/actions/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.

from typing import Optional, Union

from typing import Any, Optional, Union

from selenium.webdriver.remote.command import Command

Expand All @@ -40,7 +41,7 @@ def __init__(
mouse = mouse or PointerInput(interaction.POINTER_MOUSE, "mouse")
keyboard = keyboard or KeyInput(interaction.KEY)
wheel = wheel or WheelInput(interaction.WHEEL)
self.devices = [mouse, keyboard, wheel]
self.devices: list[Union[PointerInput, KeyInput, WheelInput]] = [mouse, keyboard, wheel]
self._key_action = KeyActions(keyboard)
self._pointer_action = PointerActions(mouse, duration=duration)
self._wheel_action = WheelActions(wheel)
Expand All @@ -62,11 +63,11 @@ def get_device_with(self, name: str) -> Optional[Union["WheelInput", "PointerInp

@property
def pointer_inputs(self) -> list[PointerInput]:
return [device for device in self.devices if device.type == interaction.POINTER]
return [device for device in self.devices if isinstance(device, PointerInput)]

@property
def key_inputs(self) -> list[KeyInput]:
return [device for device in self.devices if device.type == interaction.KEY]
return [device for device in self.devices if isinstance(device, KeyInput)]

@property
def key_action(self) -> KeyActions:
Expand Down Expand Up @@ -159,7 +160,7 @@ def perform(self) -> None:
>>> el = driver.find_element(id: "some_id")
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
"""
enc = {"actions": []}
enc: dict[str, list[Any]] = {"actions": []}
for device in self.devices:
encoded = device.encode()
if encoded["actions"]:
Expand Down
Loading