Skip to main content

Overview

Gesture methods allow you to simulate touch interactions at specific screen coordinates. These methods use Android’s GestureDescription API to dispatch touch events.
Gesture methods require API 24 (Android 7.0) or higher. The methods will log a warning and return early on older Android versions.

Tap Gestures

Simulate Click

Simulate a tap at specific screen coordinates.
Float
required
The X coordinate in pixels (horizontal position from left edge)
Float
required
The Y coordinate in pixels (vertical position from top edge)
Example:
The tap gesture has a 50ms duration. This simulates a quick tap that most apps will recognize as a click event.

Swipe Gestures

Simulate Swipe

Simulate a swipe gesture from one point to another.
Float
required
The starting X coordinate in pixels
Float
required
The starting Y coordinate in pixels
Float
required
The ending X coordinate in pixels
Float
required
The ending Y coordinate in pixels
Example:
The swipe gesture has a 500ms duration, creating a smooth scrolling motion that mimics natural user interaction.

Scroll Gestures

Scroll to Bottom

Simulate a vertical swipe to scroll down the page.
Example:
This method performs a swipe from Y=1200 to Y=300 at X=300, creating a downward scroll motion. The gesture duration is 700ms.

Scroll to Bottom (Custom X)

Scroll down at a specific horizontal position.
Int
required
The X coordinate where the scroll should occur
Example:
Useful for scrolling specific panels or sections of the screen in multi-column layouts.

Scroll to Top

Simulate a vertical swipe to scroll up the page.
Example:
This method performs a swipe from Y=1100 to Y=1400 at X=550, creating an upward scroll motion. The gesture duration is 700ms.

Coordinate System

Understanding the Android screen coordinate system:
  • Origin (0, 0): Top-left corner of the screen
  • X-axis: Increases from left to right
  • Y-axis: Increases from top to bottom
  • Dimensions: Vary by device (e.g., 1080×1920 for Full HD phones)

Getting Screen Dimensions

To make your gestures device-independent:

Advanced Gesture Techniques

Getting Node Bounds

Combine node finding with gesture tapping:

Multi-Step Gestures

Create complex interactions with sequential gestures:

Pinch and Zoom

Pinch and zoom gestures require multi-touch support and are not directly implemented. You would need to create custom GestureDescription with multiple strokes.
Example concept (not implemented in current API):

Timing and Delays

Proper timing is crucial for reliable automation:
  • After click: 300-500ms
  • After page navigation: 1000-2000ms
  • After scroll: 500-1000ms
  • After text input: 200-500ms
  • Between rapid taps: 50-100ms

Gesture Fallback Patterns

The service uses a three-tier approach for clicking:
  1. Semantic click: Try node.performAction(ACTION_CLICK)
  2. Parent click: Bubble up to find clickable parent
  3. Gesture click: Tap at center coordinates as fallback
This is implemented in internal helper methods:

Error Handling

Gesture methods handle errors gracefully:

Best Practices

Prefer element-based clicking (by view ID, content description) over coordinate-based tapping when possible
Use relative coordinates (percentages of screen size) instead of absolute pixels for device independence
Add appropriate delays after gestures to allow animations and UI updates to complete
Test gestures on multiple screen sizes and densities
Avoid hardcoding coordinates - they will fail on different devices and orientations
Rapid repeated gestures may be throttled by the system or ignored by apps

Common Patterns

Infinite Scroll Loading

Pull to Refresh

Dismiss Bottom Sheet


Debugging Gestures

Enable touch visualization to debug gesture coordinates:
Log gesture coordinates:

API Reference


Next Steps

Node Operations

Learn element-based interaction methods

Overview

Return to Accessibility Service overview