1616# under the License.
1717
1818from typing import List
19+ from typing import Optional
1920from typing import Union
2021
2122from selenium .webdriver .remote .command import Command
3031
3132
3233class ActionBuilder :
33- def __init__ (self , driver , mouse = None , wheel = None , keyboard = None , duration = 250 ) -> None :
34+ def __init__ (
35+ self ,
36+ driver ,
37+ mouse : Optional [PointerInput ] = None ,
38+ wheel : Optional [WheelInput ] = None ,
39+ keyboard : Optional [KeyInput ] = None ,
40+ duration : int = 250 ,
41+ ) -> None :
3442 if not mouse :
3543 mouse = PointerInput (interaction .POINTER_MOUSE , "mouse" )
3644 if not keyboard :
@@ -43,7 +51,7 @@ def __init__(self, driver, mouse=None, wheel=None, keyboard=None, duration=250)
4351 self ._wheel_action = WheelActions (wheel )
4452 self .driver = driver
4553
46- def get_device_with (self , name ) -> Union ["WheelInput" , "PointerInput" , "KeyInput" ]:
54+ def get_device_with (self , name : str ) -> Union ["WheelInput" , "PointerInput" , "KeyInput" ]:
4755 return next (filter (lambda x : x == name , self .devices ), None )
4856
4957 @property
@@ -66,17 +74,17 @@ def pointer_action(self) -> PointerActions:
6674 def wheel_action (self ) -> WheelActions :
6775 return self ._wheel_action
6876
69- def add_key_input (self , name ) -> KeyInput :
77+ def add_key_input (self , name : str ) -> KeyInput :
7078 new_input = KeyInput (name )
7179 self ._add_input (new_input )
7280 return new_input
7381
74- def add_pointer_input (self , kind , name ) -> PointerInput :
82+ def add_pointer_input (self , kind : str , name : str ) -> PointerInput :
7583 new_input = PointerInput (kind , name )
7684 self ._add_input (new_input )
7785 return new_input
7886
79- def add_wheel_input (self , name ) -> WheelInput :
87+ def add_wheel_input (self , name : str ) -> WheelInput :
8088 new_input = WheelInput (name )
8189 self ._add_input (new_input )
8290 return new_input
@@ -94,5 +102,5 @@ def clear_actions(self) -> None:
94102 """Clears actions that are already stored on the remote end."""
95103 self .driver .execute (Command .W3C_CLEAR_ACTIONS )
96104
97- def _add_input (self , new_input ) -> None :
105+ def _add_input (self , new_input : Union [ KeyInput , PointerInput , WheelInput ] ) -> None :
98106 self .devices .append (new_input )
0 commit comments