October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

How to Automate Gesture Testing with Appium

Use UiAutomator2 gesture extensions for common Android interactions, W3C Actions for custom sequences, and the separate XCUITest stack for iOS.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For Android gesture tests, create an Appium session with the UiAutomator2 driver, then use its mobile: gesture extensions for actions such as scrolling, swiping, long-pressing, and pinching. For a custom multi-step pointer path, use W3C Actions. iOS uses the separate XCUITest stack; do not copy UiAutomator2 gesture commands into an iOS test.

Choose the gesture method for your platform

Method Best for Platform and scope
UiAutomator2 mobile:*Gesture extensions Common Android gestures expressed as a single action, such as scroll, swipe, click, long click, drag, fling, or pinch Android with UiAutomator2; driver-specific commands
W3C Actions Custom pointer paths or more complicated, sequenced input Use when the driver shortcut does not express the interaction; follow the chosen client and driver documentation
XCUITest driver iOS app automation Separate Appium stack involving Xcode, WebDriverAgent, XCUITest, macOS, and an iOS simulator or device

The UiAutomator2 driver recommends its gesture shortcuts for simple interactions and W3C Actions for more complicated gestures. The shortcut commands are not a universal cross-platform API. Check the documentation matching your installed driver version: UiAutomator2 mobile gestures and Appium gesture guide.

Install Appium and create a session

An Appium test needs the Appium server, a platform driver and its dependencies, and a client library. The client connects to the server through a session and sends commands through that session. Follow the Appium quickstart for the current installation sequence. The official Python client is distributed as Appium-Python-Client; Appium also maintains clients for Java, Ruby, and .NET. Third-party clients are available too, but a W3C WebDriver-compatible client may not implement every Appium-specific command. See the Appium client ecosystem.

Python session and Android scroll example

Install the Python client with pip install Appium-Python-Client. Start the Appium server and make an Android device or emulator available with the required UiAutomator2 dependencies. Replace the app path and element locator with values for your test app. The example scrolls a target container until it can no longer scroll down, subject to a safety limit, then checks for an app-specific destination element.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy

options = UiAutomator2Options()
options.platform_name = "Android"
options.automation_name = "UiAutomator2"
options.device_name = "Android Emulator"
options.app = "/absolute/path/to/your-app.apk"

driver = webdriver.Remote("http://127.0.0.1:4723", options=options)
try:
    # Use a locator for the actual scrollable container in your app.
    container = driver.find_element(AppiumBy.ID, "com.example:id/list")

    # The return value is True while more scrolling is possible downward.
    for _ in range(12):
        can_scroll_more = driver.execute_script(
            "mobile: scrollGesture",
            {
                "elementId": container.id,
                "direction": "down",
                "percent": 0.75,
            },
        )
        if not can_scroll_more:
            break

    # Assert the observable result your app is expected to produce.
    driver.find_element(AppiumBy.ACCESSIBILITY_ID, "Destination item")
finally:
    driver.quit()

This uses the Appium Python client’s remote-session pattern and UiAutomator2’s documented extension call. Client method signatures can differ; consult your selected client’s documentation and the installed driver’s matching gesture reference. The official Python session example demonstrates session creation and teardown, not gesture behavior: Appium Python quickstart example.

Use UiAutomator2 gestures for common Android actions

These commands are invoked through the client’s script-execution method with a map of arguments. In Python that commonly looks like driver.execute_script("mobile: scrollGesture", { ... }); Java uses executeScript. Exact signatures depend on the client.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Command Purpose Targeting and key inputs
mobile: clickGesture Tap using the driver gesture extension Use an element or coordinates where supported; the driver documents it as a possible workaround if a native tap fails despite apparently correct coordinates.
mobile: doubleClickGesture Double-click or double-tap interaction Use the supported element or coordinate target form from the driver documentation.
mobile: longClickGesture Long press Accepts an element or coordinates; duration is in milliseconds, with 500 ms documented as the default.
mobile: dragGesture Drag an item Use the documented target and destination inputs for your driver version.
mobile: swipeGesture Swipe through a target region For an area, provide left, top, width, and height, plus direction and percent. Speed is configurable.
mobile: scrollGesture Scroll a target element or bounded region Direction is up, down, left, or right. Area form takes bounds; percent must be greater than zero. 1.0 means 100% of the area. Speed is configurable. Returns whether further scrolling is possible in that direction.
mobile: flingGesture Perform a faster, fling-like movement Use the supported element or area form and documented speed options.
mobile: pinchOpenGesture / mobile: pinchCloseGesture Spread or pinch together For a bounded region, provide left, top, width, and height.

Consult the driver command reference for the precise arguments supported by your installed version. Use mobile: scroll when the goal is to seek a selector; use mobile: scrollGesture when the test should perform directional scrolling and use its “can scroll further” result.

Element targets versus screen regions

Prefer an element target when the command supports it and the element represents the interaction surface. This ties the test to app semantics rather than a particular screen coordinate. Use area bounds when the gesture is inherently about a region, such as scrolling a particular panel or pinching within an image. For area-based scroll, swipe, or pinch, define left, top, width, and height in the coordinate space expected by the driver. Avoid bounds that include adjacent controls or another scrollable container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Control distance, direction, duration, and speed

For scroll and swipe, choose a direction and percent that reflect the user action. A percent of 1.0 represents the full area; a larger gesture is not automatically a better test because it can skip intermediate states. Set speed when it matters to the behavior under test and record that choice in the test. For a long press, set duration explicitly when the app distinguishes press lengths; otherwise the documented default is 500 ms.

Assert the app result, not just the input command

A gesture command completing without an error only shows that the automation request ran. It does not establish that the app handled the gesture correctly. Assert an observable result tied to the scenario: a destination label becomes visible, a value changes, a menu opens, an item moves, or a known end-of-list state appears.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • Wait for the screen or control needed by the test before interacting; prefer an explicit condition over an unexplained sleep.
  • Use the narrowest meaningful target element or region so the gesture cannot accidentally act on a neighboring control.
  • For repeated scrolling, stop when scrollGesture returns false and impose a loop limit, as in the example.
  • Run the scenario across the device and OS combinations the app supports; gesture geometry and timing can vary by screen and environment.

These are test-design practices, not guarantees that a gesture will behave identically on every device.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use W3C Actions for a custom pointer sequence

A gesture shortcut is clearer for a standard swipe or long press. When the action needs a particular sequence of pointer movements or multiple coordinated steps, use the W3C Actions model supported by your chosen client and driver. Follow that client’s current API documentation and Appium’s guidance for complex gestures and W3C Actions; do not assume an Android-specific extension can be issued unchanged on another platform.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Keep iOS gesture automation separate

On iOS, Appium’s XCUITest driver coordinates the Appium client and server with WebDriverAgent, Xcode, XCUITest, macOS, and an iOS simulator or device. That is a different stack from Android’s UiAutomator2 driver. Diagnose failures against the relevant layer: test code and client, Appium server, installed driver, Xcode/WebDriverAgent tooling, or the target device.

The current command syntax for XCUITest gestures is not established here, so this article does not provide an iOS gesture call or reuse Android’s mobile:*Gesture commands as iOS instructions. Check the current XCUITest driver documentation and the chosen client’s documentation before implementing one. The older Appium swipe tutorial is archived and should not be treated as current command-reference material.

Troubleshoot common failures

The session cannot start

  • Likely cause: the server is not running, the requested driver is not installed, or the device/app capabilities do not match the available environment.
  • Fix: follow the current quickstart, confirm the platform driver and its dependencies are installed, and check that the device or emulator is available and the app path is valid.

The gesture extension is reported as unknown or unsupported

  • Likely cause: the session is using a different platform driver, an incompatible driver version, or a client that does not expose the needed Appium extension.
  • Fix: verify the session’s automation name and installed driver, then compare the command with that driver version’s gesture documentation. Appium-specific commands are not necessarily implemented by every third-party client.

A scroll or swipe moves the wrong content

  • Likely cause: the element or region covers the wrong container, or the bounds include nearby interactive content.
  • Fix: target the intended scrollable element if supported. Otherwise tighten the region bounds and check direction and percent.

A tap misses despite plausible coordinates

  • Likely cause: coordinate-based input is sensitive to layout and device dimensions, or the ordinary tap path is not working as expected.
  • Fix: use a semantic element target where possible. For Android, the UiAutomator2 documentation identifies mobile: clickGesture as a possible driver-specific workaround when a native tap fails despite apparently correct coordinates; it is not a universal replacement for element interaction.

A scroll loop never reaches its target

  • Likely cause: the destination is absent, the wrong container is scrolling, or the loop does not have a stopping condition.
  • Fix: assert that the target exists in the expected screen state, use the scrollGesture boolean to stop when no more scrolling is possible, and retain an explicit iteration limit.

The command succeeds but the test still fails

  • Likely cause: the test checks only command completion, or the app has not yet reached the state being asserted.
  • Fix: wait for a relevant app condition and assert the visible outcome of the gesture rather than treating a successful automation call as proof of app behavior.

Or skip the browser setup:

ScreenshotNeo is a website screenshot API and MCP server for developers, not a replacement for Appium’s interactive mobile-device gesture testing. For a web page capture, one GET request returns an image or PDF:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation. It removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.