From 258f67066a42eb481ecfd28b7fb80c4fca12c6e0 Mon Sep 17 00:00:00 2001 From: ianxiaohanxu Date: Tue, 9 Sep 2014 09:25:18 +0800 Subject: [PATCH] Make long_press works with 'duration' parameter. Add a new parameter 'duration = None' to _get_opts --- appium/webdriver/common/touch_action.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/appium/webdriver/common/touch_action.py b/appium/webdriver/common/touch_action.py index 303f6ca6..ccc542c5 100644 --- a/appium/webdriver/common/touch_action.py +++ b/appium/webdriver/common/touch_action.py @@ -57,7 +57,7 @@ def press(self, el=None, x=None, y=None): def long_press(self, el=None, x=None, y=None, duration=1000): """Begin a chain with a press down that lasts `duration` milliseconds """ - self._add_action('longPress', self._get_opts(el, x, y)) + self._add_action('longPress', self._get_opts(el, x, y, duration)) return self @@ -112,7 +112,7 @@ def _add_action(self, action, options): } self._actions.append(gesture) - def _get_opts(self, element, x, y): + def _get_opts(self, element, x, y, duration = None): opts = {} if element is not None: opts['element'] = element.id @@ -122,6 +122,9 @@ def _get_opts(self, element, x, y): x, y = None, None opts['x'] = x opts['y'] = y + + if duration is not None: + opts['duration'] = duration return opts