Skip to content

Commit 53dedda

Browse files
authored
add a duration for scroll for ios (#256)
* add a duration for scroll for ios * tweak default duration * apply autoformat * set 600 duration by default if it's w3c spec * skip wait if duration is none * add comment
1 parent 5acf272 commit 53dedda

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

appium/webdriver/webdriver.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,27 @@ def create_web_element(self, element_id):
425425
return MobileWebElement(self, element_id)
426426

427427
# convenience method added to Appium (NOT Selenium 3)
428-
def scroll(self, origin_el, destination_el):
428+
def scroll(self, origin_el, destination_el, duration=None):
429429
"""Scrolls from one element to another
430430
431431
:Args:
432432
- originalEl - the element from which to being scrolling
433433
- destinationEl - the element to scroll to
434+
- duration - a duration after pressing originalEl and move the element to destinationEl. Default is 600 ms for W3C spec. Zero for MJSONWP.
434435
435436
:Usage:
436437
driver.scroll(el1, el2)
437438
"""
439+
440+
# XCUITest x W3C spec has no duration by default in server side
441+
if self.w3c and duration is None:
442+
duration = 600
443+
438444
action = TouchAction(self)
439-
action.press(origin_el).move_to(destination_el).release().perform()
445+
if duration is None:
446+
action.press(origin_el).move_to(destination_el).release().perform()
447+
else:
448+
action.press(origin_el).wait(duration).move_to(destination_el).release().perform()
440449
return self
441450

442451
# convenience method added to Appium (NOT Selenium 3)

0 commit comments

Comments
 (0)