Gestures

The XCUITest driver provides multiple options for touch gestures automation. For simple gestures, like tap by coordinates, long tap, multi-finger tap, double/triple tap, swipe, drag, rotate, scroll or pinch use the below gesture shortcuts:

For more sophisticated gestures consider using W3C actions.

Make sure you don't use deprecated JSONWP TouchActions APIs. They have been removed from the XCUITest driver since version 7.

If the action code in the client source looks good and satisfies the above requirements, but its execution still does not deliver the expected result then the following debugging measures might be applied:

  • Make sure the gesture has valid coordinates and respects pauses between pointer state changes. For example, it is always mandatory to provide a valid element or valid absolute coordinates to any gesture at the beginning. iOS only registers a long touch/click if the pointer has been depressed for longer than 500ms. For shorter actions a simple click is registered instead.
  • If your tests run on Simulator then it is possible to activate pointer tracing by enabling the appium:simulatorTracePointer capability or by enabling Visual Indicators items from Simulator settings. After running your automation code with this feature enabled you would be able to see the exact pointer trace path and check the velocity of the gesture. Compare the trace to how the same gesture is usually done manually and apply the necessary updates to your code.
  • Do not mix webview and native elements in actions arguments. It simply won't work. Native actions could only consume native elements. A single possibility to perform a native action on a web element would be to translate its coordinates into the native context and pass these coordinates as native action arguments.

Check the below tutorials for more details on how to build reliable action chains: