diff --git a/py/selenium/webdriver/common/actions/action_builder.py b/py/selenium/webdriver/common/actions/action_builder.py index 211217edd7140..48859832de0e7 100644 --- a/py/selenium/webdriver/common/actions/action_builder.py +++ b/py/selenium/webdriver/common/actions/action_builder.py @@ -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 @@ -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) @@ -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: @@ -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"]: