Sitelet https://github.com/appium/python-client/commit/686d4864185b86bc61038099be116ec68fe3c0c9
Skip to content

Commit 686d486

Browse files
authored
feat: add pause in drag_and_drop (#961)
* feat: add pause in drag_and_drop * docs: tweak docstring * Update action_helpers.py * apply pause only when the value is not negative
1 parent 2e0ff4e commit 686d486

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎appium/webdriver/extensions/action_helpers.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,24 @@ def scroll(self, origin_el: WebElement, destination_el: WebElement, duration: Op
6161
actions.perform()
6262
return cast('WebDriver', self)
6363

64-
def drag_and_drop(self, origin_el: WebElement, destination_el: WebElement) -> 'WebDriver':
64+
def drag_and_drop(
65+
self, origin_el: WebElement, destination_el: WebElement, pause: Optional[float] = None
66+
) -> 'WebDriver':
6567
"""Drag the origin element to the destination element
6668
6769
Args:
6870
origin_el: the element to drag
6971
destination_el: the element to drag to
72+
pause: how long the action pauses before moving after the tap and hold, in float seconds.
7073
7174
Returns:
7275
Union['WebDriver', 'ActionHelpers']: Self instance
7376
"""
7477
actions = ActionChains(self)
7578
# 'mouse' pointer action
7679
actions.w3c_actions.pointer_action.click_and_hold(origin_el)
80+
if pause is not None and pause > 0:
81+
actions.w3c_actions.pointer_action.pause(pause)
7782
actions.w3c_actions.pointer_action.move_to(destination_el)
7883
actions.w3c_actions.pointer_action.release()
7984
actions.perform()

0 commit comments

Comments
 (0)