---
title: Using Touch Actions with Appium | Testing Resources
description: How to simulate taps, swipes and pinches on real devices with Appium
  Touch Actions, with examples, best practices and common pitfalls.
source_url:
  html: https://testingbot.com/resources/articles/touch-actions-appium
  md: https://testingbot.com/resources/articles/touch-actions-appium.md
---

![Using Touch Actions with Appium](https://testingbot.com/assets/resources/articles/24.webp)

# How to use touch actions with Appium?

How to simulate taps, swipes and pinches on real devices with Appium Touch Actions, with examples, best practices and common pitfalls.

By [Jochen D.](https://testingbot.com/about/jochen-d)2023-07-18Updated 2026-08-31

 Share on Facebook 

 Share on Twitter 

 Post on Reddit 

 Share link 

> **Updated for Appium 3.** The `TouchAction` and `MultiAction` APIs this article originally used have been **removed** , not merely deprecated. Appium 3 deleted the underlying endpoints, including `/touch/perform` and `/touch/multi/perform`, and maps them onto the [W3C Actions API](https://www.selenium.dev/documentation/webdriver/actions_api/) (`POST /session/:sessionId/actions`). Code written against `TouchAction` will not run on a current Appium server.
> 
> There are two supported ways to express a gesture now, and both are shown below: the portable **W3C Actions API** , and the driver-specific **`mobile:` gesture execute methods** , which are usually shorter and more reliable for common gestures. Checked against Appium 3.7.0 on 31 August 2026.

Touch Actions in [Appium](https://testingbot.com/support/app-automate/appium) are a set of mobile automation commands, which can be used to simulate user interactions in the context of a touch screen device. The actions will mimic the gestures and touches of a user holding a touch device (such as a smartphone). Using touch actions means you can mimic various interactions that one usually does on a phone, such as:

- Tap
- Swipe
- Pinch

In this article will give an overview on how to mimck these actions in your automated Appium tests, running on mobile devices.

## Table of Contents

- [What are the various Touch Actions in Appium?](https://testingbot.com#actions)
- [Installing and Configuring Appium](https://testingbot.com#configure)
- [Examples using Touch Actions with Appium](https://testingbot.com#examples)
- [Best practices when using Touch Actions with Appium](https://testingbot.com#practices)
- [Common problems when using Touch Actions with Appium](https://testingbot.com#issues)

## What are the various Touch Actions in Appium?

Below is a list of the most commonly used touch actions with Appium:

- Swipe
- Tap
- Pinch
- Long Press

### Swipe

A swipe is an action where you start from an x, y (start) position and keep one or more fingers down on the screen. The swipe will stop when you reach another x, y (end) position and lift all fingers up. This logic can be written in code:

```python
driver.execute_script('mobile: swipeGesture', {
    'left': startx, 'top': starty, 'width': width, 'height': height,
    'direction': 'left', 'percent': 0.75,
})
```

The code will perform an action where a long press will start from the start position. Moving to the end position where a release is called.

### Tap

A tap is a simple click on a coordinate of the screen. You will require both the x and y coordinate to perform the tap, or an element. In case of an element, Appium will find the coordinates of the center of the element.

```python
element = driver.find_element(AppiumBy.XPATH, '//android.widget.TextView[@content-desc="tb-btn"]')

driver.execute_script('mobile: clickGesture', {'elementId': element.id})
```

### Pinch

A pinch is where you use two fingers on the screen. For example, you can use a pinch to zoom in or out of the screen's content. If you move your fingers to the opposite of each other, you can zoom-in.

```python
driver.execute_script('mobile: pinchOpenGesture', {
    'elementId': element.id,
    'percent': 0.75,
})
```

### Long Press

With a long press (also known as press-and-hold), you can press an element or coordinate for a longer duration than a tap, with one or more fingers (or a stylus). For example, on iOS this can be used to show a context-sensitive menu.

```python
driver.execute_script('mobile: longClickGesture', {
    'elementId': element.id,
    'duration': 1000,
})
```

## Installing and Configuring Appium

To install and configure Appium, you'll need to follow these general steps:

### Prerequisites

Make sure you have NodeJS installed on your machine. You can download it from the [NodeJS website](https://nodejs.org).

### Install Appium

You can easily install Appium with NPM or Yarn.

```bash
npm install -g appium
```

### Install Appium Dependencies

Depending on the mobile platform you want to run on, you might need to make sure you have the necessary dependencies installed.

For Android, make sure you have installed the [Android SDK](https://developer.android.com/sdk).

For iOS, make sure you have installed the XCode version that works with the iOS version you want to test on.

### Run Appium

To run Appium simply run the **appium** command in your terminal. Appium will automatically listen on port 4723.

## Examples using Touch Actions with Appium

Below are some examples on how to use Appium and Touch Actions, with Python. These examples will connect to the TestingBot device grid.

```python
from appium import webdriver
from appium.options.android import UiAutomator2Options
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput

options = UiAutomator2Options().load_capabilities({
    'platformName': 'Android',
    'appium:platformVersion': '13',
    'appium:deviceName': 'Pixel 7',
    'appium:appPackage': 'com.testingbot.demo.app',
})

driver = webdriver.Remote('https://hub.testingbot.com/wd/hub', options=options)

size = driver.get_window_size()
start_x = size['width'] * 8 // 9
end_x = size['width'] // 9
y = size['height'] // 2

# W3C Actions: one virtual finger, pressed down, dragged, lifted.
finger = PointerInput(interaction.POINTER_TOUCH, 'finger')
actions = ActionBuilder(driver, mouse=finger)
actions.pointer_action.move_to_location(start_x, y)
actions.pointer_action.pointer_down()
actions.pointer_action.pause(0.2)
actions.pointer_action.move_to_location(end_x, y)
actions.pointer_action.pointer_up()
actions.perform()

driver.quit()
```

For a plain swipe the UiAutomator2 driver's own gesture command is shorter, and it handles the timing for you:

```python
driver.execute_script('mobile: swipeGesture', {
    'left': 100,
    'top': 100,
    'width': 200,
    'height': 200,
    'direction': 'left',
    'percent': 0.75,
})
```

```python
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy

options = UiAutomator2Options().load_capabilities({
    'platformName': 'Android',
    'appium:platformVersion': '13',
    'appium:deviceName': 'Pixel 7',
    'appium:appPackage': 'com.testingbot.demo.app',
})

driver = webdriver.Remote('https://hub.testingbot.com/wd/hub', options=options)

element = driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'map')

# Zoom in. Use pinchCloseGesture to zoom back out.
driver.execute_script('mobile: pinchOpenGesture', {
    'elementId': element.id,
    'percent': 0.75,
})

driver.quit()
```

## Best practices when using Touch Actions with Appium

When using touch actions with Appium, it's important to follow best practices to ensure reliable and effective test automation. Below are some best practices that you can integrate in your tests:/p\>

### Use Touch Action Chaining

You can chain various touch actions in a sequence. This allows you to combine various gestures and create complex interactions, such as various swipe, drag and tap combinations.

### Use Real-Device Testing

While emulators and simulators are useful for initial testing, consider performing touch action testing on physical devices as well. Physical devices may have subtle differences in touch behavior and performance compared to emulators/simulators.

### Handle Different Screen Resolutions

Make sure you are testing your touch actions on devices with various screen resolutions. You need to make sure your automated tests work on different devices, with different resolutions.

## Common problems when using Touch Actions with Appium

When using touch actions with Appium, you may encounter some common issues. Below are some examples:

### Element Identification

Identifying the correct elements to perform touch actions on can be difficult. Make sure that you use appropriate locators (such as IDs, class names, or XPath) to accurately identify the elements you want to interact with.

### Timing and Synchronization

Mobile apps can have varying response times, which means touch actions need to be timed correctly. Make sure you are using implicit or explicit waits to check if the element that you want to interact with is available to the automated test.

### Calibration and Offset

Some devices might be using software that change the layout of some OS elements. Especially low end Android devices, or Android devices from specific manufacturers may use their own custom OS. This might introduce UI elements that do not appear on other devices.

If that is the case, it's important to make sure that if you use x and y coordinates, to take this into consideration.

### Performance

Automated touch actions can sometimes impact the performance and stability of the app or the test environment. Long-running or repetitive touch actions may cause memory leaks, performance degradation, or crashes. Consider optimizing your test scripts and reducing unnecessary touch actions to maintain stability and efficiency.

Topics [Mobile App Testing](https://testingbot.com/resources/articles/topic/mobile-testing) 

## Sidebar

### TestingBot Cloud Testing

Run automated, manual and visual tests on remote browsers and devices. Sign up for a free trial.

[Free Trial](https://testingbot.com/users/sign_up)

### Latest articles

[![Mobile App Test Automation at Scale](https://testingbot.com/assets/resources/articles/mobile-app-test-automation-12d7e7edc7c551f05282cd03ccd0de42da8e4c740d754286777972249471a36e.webp)](https://testingbot.com/resources/articles/mobile-app-test-automation)

#### [Mobile App Test Automation at Scale](https://testingbot.com/resources/articles/mobile-app-test-automation)

How to choose between Appium, Espresso, XCUITest and Maes...

[Read article →](https://testingbot.com/resources/articles/mobile-app-test-automation)

[![Run Maestro tests in the cloud](https://testingbot.com/assets/resources/articles/45-54aab6a840d2561eab846e8bfde7ec26113ba601a9fcc15ddea883c2a80ec29c.webp)](https://testingbot.com/resources/articles/maestro-cloud-testing)

#### [Run Maestro tests in the cloud](https://testingbot.com/resources/articles/maestro-cloud-testing)

What Maestro is, how its declarative flows differ from Ap...

[Read article →](https://testingbot.com/resources/articles/maestro-cloud-testing)

[![Appium 2 and Appium 3 Migration Guide](https://testingbot.com/assets/resources/articles/27-121da26036885301ba438e1cdfc81e7ae8045cbc53c0dafaff5b4436000590b1.webp)](https://testingbot.com/resources/articles/appium-2-migration)

#### [Appium 2 and Appium 3 Migration Guide](https://testingbot.com/resources/articles/appium-2-migration)

What changed between Appium 1, 2 and 3: drivers, capabili...

[Read article →](https://testingbot.com/resources/articles/appium-2-migration)

## Other Articles

[![Automate native iOS Apps with XCUITest](https://testingbot.com/assets/resources/articles/25-bb2ccb531384c461ef792214839e9e8f99a4b08b1293730ceeab67e4a8352563.webp)](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest "Automate native iOS Apps with XCUITest")

### [Automate native iOS Apps with XCUITest](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

How to automate Apple's own iOS apps with XCUITest, with code for driving Settings, Messages and Photos, and how to extend it to other apps.

[Read article →](https://testingbot.com/resources/articles/automate-native-ios-apps-xcuitest)

[![How to Inspect Element using UIAutomatorViewer](https://testingbot.com/assets/resources/articles/23-d6314d62f1aa6a6c51fb960d1b65bc3aeb14ee0ade20527f6546bfd5777536d2.webp)](https://testingbot.com/resources/articles/android-uiautomatorviewer "How to Inspect Element using UIAutomatorViewer")

### [How to Inspect Element using UIAutomatorViewer](https://testingbot.com/resources/articles/android-uiautomatorviewer)

How to use UIAutomatorViewer from the Android SDK to inspect app screens and find the selectors your automated Android tests need.

[Read article →](https://testingbot.com/resources/articles/android-uiautomatorviewer)

[![Dark Mode Testing with Appium](https://testingbot.com/assets/resources/articles/22-ed15fa0f3fde7566416fff5078b44689dc274439b2fb829f8c68603e909a65d6.webp)](https://testingbot.com/resources/articles/dark-mode-testing "Dark Mode Testing with Appium")

### [Dark Mode Testing with Appium](https://testingbot.com/resources/articles/dark-mode-testing)

How to switch a native app between light and dark mode from an Appium test on iOS and Android, and the layout bugs dark mode tends to expose.

[Read article →](https://testingbot.com/resources/articles/dark-mode-testing)

[![Android Espresso Tutorial](https://testingbot.com/assets/resources/articles/19-fe4971eb8049097c25f2cc2fce95b71b94f3bb342e094c219b2404c09374f015.webp)](https://testingbot.com/resources/articles/android-espresso-testing "Android Espresso Tutorial")

### [Android Espresso Tutorial](https://testingbot.com/resources/articles/android-espresso-testing)

Why Espresso suits Android UI testing, how to add it to a project and write a first test, and how it compares with the alternatives.

[Read article →](https://testingbot.com/resources/articles/android-espresso-testing)

## Ready to start testing?
[Start a free trial](https://testingbot.com/users/sign_up)
