buttons

 

ADB Concepts : How to Simulate a swipe (or drag) gesture on a Android device Using “ADB Commands”

Command — adb shell input swipe <x1> <y1> <x2> <y2> [duration(ms)]

Get a step-by-step walkthrough in the video below!

‘Swipe’ Command:

The adb shell input swipe command is used to simulate a swipe (or drag) gesture on an Android device from your computer via ADB (Android Debug Bridge). It is part of the adb shell input command suite, which allows you to simulate user input like taps, swipes, key events, etc.

Basic Syntax:

Explanation:

adb: Android Debug Bridge tool

shell: Executes a shell command on the device

input: Command to simulate user input

swipe: Simulates a finger swipe on the screen

<x1>: Horizontal screen coordinate (in pixels)

<y1>: Vertical screen coordinate (in pixels)

<x2>: Horizontal screen coordinate (in pixels)

<y2>: Vertical screen coordinate (in pixels)

duration(ms): Swipe duration in milliseconds(Optional)

Example Usage:

Perform Swipe Without duration:

Example:

Perform Swipe With duration(millseconds):

This simulates a swipe at the coordinates (560, 1800, 560, 490) on the device screen.

Example:

Use Cases:

1.Automating UI testing

2.Bypassing parts of an app manually (e.g., skip splash screens)

3.Scripting user behavior for demos or data entry

Notes:

Coordinates depend on screen resolution and orientation. Make sure USB debugging is enabled on your Android device. You can find coordinates using screenshot tools or apps that display touch location.

GitHub Link:


No comments:

Post a Comment