Search code examples
pythonappiumappium-ios

How do I longpress on iOS?


I am trying to long press an element on my screen. I do not have it working for iOS.

On android the following works:

user_action = TouchAction(self.driver)
elementname = self.driver.find_element_by_id(element)
user_action.long_press(elementname).perform()

While on iOS this simply taps the element. I also tried putting x, y and a long duration (x=200, y=550, duration=100000), but it still acts as a simple, immediate tap.

I am using Appium 1.17.1 on macOS. I have tried with real devices and emulators.

Is there a special way of doing a long press on iOS?


Solution

  • I solved this by adding in .release() like this:

    user_action = TouchAction(self.driver)
    elementname = self.driver.find_element_by_id(element)
    user_action.long_press(elementname).release().perform()
    

    as found here: How to tap and hold (Long press) using appium for Android?