How to use touch actions in Appium?
On This Page Understanding Touch Actions in AppiumJune 06, 2026 · 14 min read · Tool Comparison
Mobile apps rely heavily on gestures like taps, swipe, and scroll. Appium supports these through touch actions, enabling naturalistic mobile test automation. Touch actions in Appium objects contain a concatenation of case. The TouchAction object is first initialized in the WebDriver and then the steps are chained together to perform the action. Understanding Touch Actions Canonical Touch Actions Installing and Setting Up Appium This article outlines different touch actions and how to implement them with Appium. There are some appium touch actions in Appium such as: 1. Swipe Press by using x, y coordinates, and duration (in seconds) Horizontal swipe by using the start and end percentage of the phone blind and a point for the height—vertical swipe by using the start and end percentage of the screen and an anchor for the width. Swipe one element to another factor. The swipe has a start and endpoints. The start point of swipe is the most crucial. The following component may prevent swipe start: covering interface/menu e.g. cope or footer & # 8211; an element that is waiting for tap and do not pass trace to scroll survey This is best to start swipe actions at the center point of the screen to make them more stable. 2. Tap Tap and click sometimes suffer from the elements not being valid anymore and returning “not able to tap element”. That said, we usually use taps on buttons. Whenever we get any job with tapping on visible elements (but appium states they aren ’ t visible, etc.) we useTouchAction.new.presson Element. So no take-care cost and it always exhort on the spot even when tap/click perform not act. 3. Long Press The act of pressing one & # 8217; s finger down on an element or former portion of the screen for a few seconds, as to activate a job or access additional selection. When we need to rotate any app icon on the screen then we need long press that app icon and then scroll it on a earpiece screen. 4. Multi-touch Multi-touch allows you to touch the screen with multiple fingers and perform action. Multi-touch is usually used for gesture like Zoom-in, Zoom-out, Drag and Drop. In Appium, multi-touch actions can be performed using theMultiTouchActionclass. This class allows you to create complex touch actions involving multiple fingers on the touch screen. Read More: Differences between Android and iOS touch actions in Appium iOS and Android both use touch actions that have a common operation & # 8211;swiping, tapping, pinch,and zoom. Both OS boot to a home screen, which is alike to a computer desktop. While an iOS home blind only has rows of app icons, Android allows the use of thingumajig, which display auto-updating details such as weather and email. The iOS user UI features an mind where user can pin their most frequently used coating. A status bar lead across at the upper side on both iOS and Android, offering information such as the clip, WiFi or cell signal, and battery life; on Android, the status bar also seeable the number of new coming email, messages, and reminders. 1. Install JDK Specify the route to the JDK version in theJAVA_HOMEenvironment variable. To do this, open the Control Panel, search forenvironment variables, in the dialogue, click Environment Variables, and then set the variable and put the value: 3. Install Appium employ the below bidding After the installation, start Appium to confirm it is working amercement. Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. Note: When installing, take precaution to select theAndroid Virtual Deviceportion as seen in the image below 5. Configure Android Virtual Devices After Successfully set-up and configuring for appium and having wandering devices managed, you can connect to it from yourTestCompleteestimator to make and run tests. Here, we will excuse how you can use different touch activeness in Appium expend Python by creating a introductory test suit for each of them. The below code helps you can perform the Tap Touch activeness in Appium The below code helps you can perform Long Press touch activeness in Appium Code : Here ’ s the code to swipe employ touch action in Appium You can start discussing with our discord community Using advanced touch action like multi-touch actions such as: Here ’ s the elaborate code for each of these complex ghost activeness. 1. Pinch & # 8211; Zoom in using multi-touch To make any ikon, web page, etc. more seeable and clear to the viewer, the zoom operation maximises and minimises the window. Or, to put it another way, when you zoom in, the coordinates (x, y) from one place change as it moves to another spot, causing a shift in co-ordinate that enlarge the window and improves user clearness. 2. Pinch Zoom-out using multi-touch A zoom-out operation reduce the size of the window for any image, webpage, etc. so that the user can see it more intelligibly and easily. Or, to put it another way, when you soar out, the coordinates (x, y) from one point modification and are shifted to another point location, which causes a modification in coordinates. This action enlarge the window and improves user lucidness. Complex Actions expend Touch Action and Multi-touch Action Here, we are do some complex actions using touch action and multi-touch in appium 3. Drag & amp; Drop Moving an element from one place to a particular or defined place command the simultaneous use of the two actions of drag and drop. An constituent & # 8217; s location, or more specifically its x and y co-ordinate, change throughout the drag and drop event and it is placed in a new location with new x and y coordinates. In order to do drag-and-drop actions inside mobile applications, Appium offers a set of instructions. The moveTo method, which is component of the Touch Action Class, helps drop the element to its intended place free-base on x and y coordinates by long-pressing the element to be cart. Read More: Code to perform Drag and Drop using Touch Actions in Appium 4. Drag & amp; Drop using an inherent function Read More: Listed below are some of the key best pattern that you can follow when using touch actions in Appium: Here are some of the common topic / challenge that you may encounter with touch activeness in Appium: Read More: Conclusion So, In this clause, we have touch action, multi-touch activity, and action chain uses with different points of survey and operation in applications for prove any app. Here we have cabbage, scroll, sweep & amp; drop operations, Zoom In, and Zoom out. Succeeding, we can try these operations by using W3C Protocol in appium. also render the environment for performing these operations with different device and versions. # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to use touch activeness in Appium?
Overview
Understanding Touch Actions in Appium
Installing and Setting Up Appium
npm install -g appium
If the dialog box doesn ’ t list the twist you need, tickCreate Virtual Deviceand create the required gimmick emulator.Creating Basic Test Script For Touch Actions
1. Using Tap Touch Action in Appium: Example
from appium import webdriver from appium.webdriver.common.touch_action importation TouchAction from appium.webdriver.common.appiumby meaning AppiumBy significance time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver target '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) ele = driver.find_element (AppiumBy.XPATH, '//android.widget.TextView [@ content-desc= '' filter-btn ''] ') # Step 3: Create the object the TouchAction category actions = TouchAction (driver) # Step 4: Call the tap () method and pass the arguments. actions.tap (ele) .perform () time.sleep (5) driver.quit ()2. Using Long Press Touch Action in Appium: Example
from appium signification webdriver from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.appiumby significance AppiumBy importee time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) ele = driver.find_element (AppiumBy.XPATH, '//android.widget.TextView [@ content-desc= '' filter-btn ''] ') # Step 3: Create the object the TouchAction grade actions = TouchAction (driver) actions.long_press (ele) actions.perform () time.sleep (5) driver.quit ()3. Swipe without Touch Action
from appium import webdriver import time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) # Step 1: Find the device width and height deviceSize = driver.get_window_size () screenWidth = deviceSize ['width '] screenHeight = deviceSize ['height '] # Step 2: # Step 6: Find the x, y co-ordinate to swipe # # * * * * * * * * * * * down to up * * * * * * * * * * * * * # startx = screenWidth/2 endx = screenWidth/2 starty = screenHeight * 8/9 endy = screenHeight/9 driver.swipe (start_x=startx, start_y=starty, end_x=endx, end_y=endy, duration=100) time.sleep (5) driver.quit ()4. Swipe with touch activity in Appium
from appium importation webdriver from appium.webdriver.common.touch_action significance TouchAction from appium.webdriver.common.appiumby import AppiumBy significance time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) ele = driver.find_element (AppiumBy.XPATH, '//android.widget.TextView [@ content-desc= '' filter-btn ''] ') # Step 3: Find the device width and height deviceSize = driver.get_window_size () print (`` Device Width and Height: ``, deviceSize) screenWidth = deviceSize ['width '] screenHeight = deviceSize ['height '] # Step 4: Find the x, y co-ordinate to swipe # * * * * * * * * * * * Left to Right * * * * * * * * * * * * * # startx = screenWidth * 8/9 endx = screenWidth/9 starty = screenHeight/2 endy = screenHeight/2 # * * * * * * * * * * * Right to Left * * * * * * * * * * * * * # startx2 = screenWidth/9 endx2 = screenWidth * 8/9 starty2 = screenHeight/2 endy2 = screenHeight/2 activeness = TouchAction (driver) # Step 5: perform the action swiping from leave to Right actions.long_press (None, startx, starty) .move_to (None, endx, endy) .release () .perform () # Step 6: do the action swiping from Right to Left actions.long_press (None, startx2, starty2) .move_to (None, endx2, endy2) .release () .perform () time.sleep (2) driver.quit () Like what you are read?
Advanced Touch Actions
from appium import webdriver from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.multi_action importee MultiAction from appium.webdriver.common.appiumby import AppiumBy import time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) ele = driver.find_element (AppiumBy.XPATH, '//android.widget.TextView [@ content-desc= '' filter-btn ''] ') # Step 3: Find the twist width and top xx = driver.get_window_size () ['width '] /2 yy = driver.get_window_size () ['height '] /2 # Step 4: Perform zoom-in action1 = TouchAction (driver) action2 = TouchAction (driver) zoom_action = MultiAction (driver) # Zoom action1.long_press (x=xx, y=yy) .move_to (x=0, y=50) .wait (500) .release () action2.long_press (x=xx, y=yy) .move_to (x=0, y=-50) .wait (500) .release () zoom_action.add (action1, action2) time.sleep (2) driver.quit ()from appium import webdriver from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.multi_action significance MultiAction from appium.webdriver.common.appiumby import AppiumBy import time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) ele = driver.find_element (AppiumBy.XPATH, '//android.widget.TextView [@ content-desc= '' filter-btn ''] ') # Step 3: Find the device breadth and height xx = driver.get_window_size () ['width '] /2 yy = driver.get_window_size () ['height '] /2 # Step 4: Perform zoom-out action1 = TouchAction (driver) action2 = TouchAction (driver) zoom_action = MultiAction (driver) # Zoom action1.long_press (x=xx-50, y=yy-50) .move_to (x=0, y=50) .wait (500) .release () action2.long_press (x=xx-50, y=yy-50) .move_to (x=0, y=-50) .wait (500) .release () zoom_action.add (action1, action2) time.sleep (2) driver.quit ()from appium import webdriver from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.multi_action significance MultiAction from appium.webdriver.common.appiumby import AppiumBy import time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) # Step 3: Find ingredient for drag and drop drag_ele = driver.find_element (AppiumBy.XPATH, ' & lt; Xpath & gt; ') drop_ele = driver.find_element (AppiumBy.XPATH, ' & lt; Xpath & gt; ') action = TouchAction (driver) action.press (drag_ele) .move_to (drop_ele, 100, 100) .release () .perform () time.sleep (2) driver.quit ()from appium import webdriver from appium.webdriver.common.touch_action signification TouchAction from appium.webdriver.common.multi_action import MultiAction from appium.webdriver.common.appiumby import AppiumBy import time # Step 1: Create `` Desired Capabilities '' desired_caps = {} desired_caps ['platformName '] = 'Android' desired_caps ['platformVersion '] = '10' desired_caps ['deviceName '] = 'Pixel3XL' desired_caps ['appPackage '] = 'com.browserstack.demo.app' desired_caps ['appActivity '] = 'host.exp.exponent.MainActivity' desired_caps ['udid '] = 'emulator-5554' # Step 2: Create `` Driver object '' driver = webdriver.Remote (`` http: //127.0.0.1:4723/wd/hub '', desired_caps) time.sleep (8) # Step 3: Find element for drag and drop drag_ele = driver.find_element (AppiumBy.XPATH, ' & lt; Xpath & gt; ') drop_ele = driver.find_element (AppiumBy.XPATH, ' & lt; Xpath & gt; ') action = TouchAction (driver) action.tap (drag_ele) .perform () driver.drag_and_drop (drag_ele, drop_ele) time.sleep (2) driver.quit ()Best Practices for using Touch Actions in Appium
Common issues / Challenges with Touch Actions in Appium
Related Guides
Automate This With SUSA
Test Your App Autonomously