1616
1717from selenium import webdriver
1818from selenium .webdriver .common .action_chains import ActionChains
19+ from selenium .webdriver .common .actions import interaction
20+ from selenium .webdriver .common .actions .action_builder import ActionBuilder
1921from selenium .webdriver .common .actions .mouse_button import MouseButton
22+ from selenium .webdriver .common .actions .pointer_input import PointerInput
2023
21- from appium .webdriver .common .multi_action import MultiAction
22- from appium .webdriver .common .touch_action import TouchAction
2324from appium .webdriver .webelement import WebElement
2425
2526if TYPE_CHECKING :
@@ -54,6 +55,7 @@ def scroll(self: T, origin_el: WebElement, destination_el: WebElement, duration:
5455 duration_sec = duration / 1000
5556
5657 actions = ActionChains (self )
58+ actions .w3c_actions = ActionBuilder (self , mouse = PointerInput (interaction .POINTER_TOUCH , "touch" ))
5759 dest_el_rect = destination_el .rect
5860
5961 # https://github.com/SeleniumHQ/selenium/blob/3c82c868d4f2a7600223a1b3817301d0b04d28e4/py/selenium/webdriver/common/actions/pointer_actions.py#L83
@@ -83,6 +85,7 @@ def drag_and_drop(self: T, origin_el: WebElement, destination_el: WebElement) ->
8385 Union['WebDriver', 'ActionHelpers']: Self instance
8486 """
8587 actions = ActionChains (self )
88+ # 'mouse' pointer action
8689 actions .w3c_actions .pointer_action .click_and_hold (origin_el )
8790 actions .w3c_actions .pointer_action .move_to (destination_el )
8891 actions .w3c_actions .pointer_action .release ()
@@ -106,6 +109,7 @@ def tap(self: T, positions: List[Tuple[int, int]], duration: Optional[int] = Non
106109 """
107110 if len (positions ) == 1 :
108111 actions = ActionChains (self )
112+ actions .w3c_actions = ActionBuilder (self , mouse = PointerInput (interaction .POINTER_TOUCH , "touch" ))
109113 x = positions [0 ][0 ]
110114 y = positions [0 ][1 ]
111115 actions .w3c_actions .pointer_action .move_to_location (x , y )
@@ -156,6 +160,7 @@ def swipe(self: T, start_x: int, start_y: int, end_x: int, end_y: int, duration:
156160 Union['WebDriver', 'ActionHelpers']: Self instance
157161 """
158162 actions = ActionChains (self )
163+ actions .w3c_actions = ActionBuilder (self , mouse = PointerInput (interaction .POINTER_TOUCH , "touch" ))
159164 actions .w3c_actions .pointer_action .move_to_location (start_x , start_y )
160165 actions .w3c_actions .pointer_action .pointer_down ()
161166 actions .w3c_actions .pointer_action .pause (duration / 1000 )
@@ -180,6 +185,7 @@ def flick(self: T, start_x: int, start_y: int, end_x: int, end_y: int) -> T:
180185 Union['WebDriver', 'ActionHelpers']: Self instance
181186 """
182187 actions = ActionChains (self )
188+ actions .w3c_actions = ActionBuilder (self , mouse = PointerInput (interaction .POINTER_TOUCH , "touch" ))
183189 actions .w3c_actions .pointer_action .move_to_location (start_x , start_y )
184190 actions .w3c_actions .pointer_action .pointer_down ()
185191 actions .w3c_actions .pointer_action .move_to_location (end_x , end_y )
0 commit comments