# How can i make a long click action with a duration parameter on Android?

**URL:** <https://discuss.appium.io/t/how-can-i-make-a-long-click-action-with-a-duration-parameter-on-android/190>\
**Category:** Support\
**Created:** [September 7, 2014, 7:44am UTC](https://discuss.appium.io/t/how-can-i-make-a-long-click-action-with-a-duration-parameter-on-android/190 "2014-09-07T07:44:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Alex](https://discuss.appium.io/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@Alex](https://discuss.appium.io/u/Alex)\
**Post date:** [September 8, 2014, 8:23am UTC](https://discuss.appium.io/t/how-can-i-make-a-long-click-action-with-a-duration-parameter-on-android/190/2 "2014-09-08T08:23:45Z")

</div>

Solved!  
It seems Appium Python client issue, we need to modify two functions in “appium.webdriver.common.touch\_action.TouchAction”

long\_press(self, el=None, x=None, y=None, duration=1000)  
and  
\_get\_opts(self, element, x, y)

Modify them like this:

```
def long_press(self, el=None, x=None, y=None, duration=1000):
    self._add_action('longPress', self._get_opts(el, x, y, duration))
    return self

def _get_opts(self, element, x, y, duration = None):
    opts = {}
    if element is not None:
        opts['element'] = element.id
    # it makes no sense to have x but no y, or vice versa.
    if x is None or y is None:
        x, y = None, None
    opts['x'] = x
    opts['y'] = y
    if duration is not None:
        opts['duration'] = duration
    return opts
```

---

_[View the full topic](https://discuss.appium.io/t/how-can-i-make-a-long-click-action-with-a-duration-parameter-on-android/190)._
