15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
17
18
- from typing import Optional , Union
18
+
19
+ from typing import Any , Optional , Union
19
20
20
21
from selenium .webdriver .remote .command import Command
21
22
@@ -40,7 +41,7 @@ def __init__(
40
41
mouse = mouse or PointerInput (interaction .POINTER_MOUSE , "mouse" )
41
42
keyboard = keyboard or KeyInput (interaction .KEY )
42
43
wheel = wheel or WheelInput (interaction .WHEEL )
43
- self .devices = [mouse , keyboard , wheel ]
44
+ self .devices : list [ Union [ PointerInput , KeyInput , WheelInput ]] = [mouse , keyboard , wheel ]
44
45
self ._key_action = KeyActions (keyboard )
45
46
self ._pointer_action = PointerActions (mouse , duration = duration )
46
47
self ._wheel_action = WheelActions (wheel )
@@ -62,11 +63,11 @@ def get_device_with(self, name: str) -> Optional[Union["WheelInput", "PointerInp
62
63
63
64
@property
64
65
def pointer_inputs (self ) -> list [PointerInput ]:
65
- return [device for device in self .devices if device . type == interaction . POINTER ]
66
+ return [device for device in self .devices if isinstance ( device , PointerInput ) ]
66
67
67
68
@property
68
69
def key_inputs (self ) -> list [KeyInput ]:
69
- return [device for device in self .devices if device . type == interaction . KEY ]
70
+ return [device for device in self .devices if isinstance ( device , KeyInput ) ]
70
71
71
72
@property
72
73
def key_action (self ) -> KeyActions :
@@ -159,7 +160,7 @@ def perform(self) -> None:
159
160
>>> el = driver.find_element(id: "some_id")
160
161
>>> action_builder.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys("keys").perform()
161
162
"""
162
- enc = {"actions" : []}
163
+ enc : dict [ str , list [ Any ]] = {"actions" : []}
163
164
for device in self .devices :
164
165
encoded = device .encode ()
165
166
if encoded ["actions" ]:
0 commit comments