On this page
You can drive an Android app from code at two levels. ADB talks to the device through its shell and sends taps and swipes by pixel coordinate. Appium sits on top of Android’s UiAutomator and finds elements on screen, so you act on a button rather than a position. In practice you reach for both. ADB handles the quick device-level stuff, and Appium handles anything that has to keep working when the screen changes.
Here’s where each one fits, and the parts that waste an afternoon if nobody warned you, for app testing and QA on devices you control.
ADB: coordinates and shell
With a device connected over ADB you can drive the screen directly:
adb shell input tap 540 1200
adb shell input swipe 540 1600 540 400 300
adb shell input text "hello"
adb shell input keyevent KEYCODE_BACK
To find out what’s on screen and where, dump the UI tree:
adb shell uiautomator dump
adb pull /sdcard/window_dump.xml
The XML lists every visible node with its bounds, so you can read the coordinates of a button and tap them. This is enough for a fixed flow on a fixed screen size, and it’s the fastest thing to set up because it needs nothing beyond the platform tools.
The limit shows up the moment the layout moves. A coordinate that hit a button on one phone lands on empty space on another resolution, and a screen that scrolls or shifts breaks a hard-coded tap. ADB has no idea what a button is; it just presses a pixel.
Appium: elements instead of pixels
Appium drives the app through Android’s UiAutomator2 driver and gives you the thing ADB lacks: you select an element by its id, text or accessibility label, and Appium finds it wherever it is on screen.
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
options = UiAutomator2Options()
options.platform_name = "Android"
options.device_name = "emulator-5554"
options.app_package = "com.example.app"
options.app_activity = ".MainActivity"
driver = webdriver.Remote("http://localhost:4723", options=options)
button = driver.find_element(AppiumBy.ID, "com.example.app:id/login")
button.click()
Because it works by element, the same script runs on different screen sizes without touching coordinates, and you get waits, so you can tell it to wait for an element to appear instead of guessing a delay. The cost is setup: you run an Appium server, the UiAutomator2 driver and a client library, where ADB is one binary.
A practical split: Appium for the flow that has to survive layout changes and different devices, and a raw adb shell call for the device-level things Appium doesn’t do, like toggling airplane mode or pushing a file.
Why adb shell input tap is unreliable
input tap is convenient and it’s also the weakest part of ADB automation. Two reasons.
It can miss. The command injects an instant down-up event at one exact pixel. If the UI is still settling, mid-animation, or a keyboard just appeared and moved things, the tap lands on whatever is under that pixel now, which may not be your button. There’s no element to confirm you hit the right thing.
And it doesn’t look like a finger. A real touch is a short path with movement, a measurable duration and pressure that ramps and falls; input tap is a single point with none of that. Any app that looks at its touch events can tell the two apart.
If you need taps that land reliably and behave more like a touch, don’t use input tap for the important ones. Options, in rough order:
- Tap through Appium by element, so the coordinate is computed from where the element actually is, after waits, not a number you wrote down.
- Use a short
input swipewith start and end a few pixels apart and a realistic duration, which produces a small movement path instead of a point. - For full control, drive W3C pointer actions (Appium’s
ActionChains/W3CActionBuilder): down, a small move, a pause of a human-plausible length, then up. Aim inside the element’s bounds rather than dead centre every time.
The theme is the same: compute the target from the live UI, and give the touch a shape in time and space instead of a single instant point.
Running the same scripts on different devices
Both ADB and Appium talk to anything that exposes an ADB connection, which is why the same script runs in several places with little change:
- Physical phones over USB or over the network with
adb connect. - Emulators from the Android SDK. Easy to script and reset, though some apps behave differently when they detect an emulator.
- Cloud phones. Services like GeeLark and DuoPlus give you hosted Android devices with ADB access, which is how you run many devices at once or get a real-hardware profile without owning the phones. You point
adb connectat the instance and the same Appium or ADB script runs against it.
The device changes, the code mostly doesn’t. Appium’s device_name and ADB’s target serial are the only things you usually swap, so you can develop against a local emulator and run against physical or cloud devices from the same script.
Where to start
If your flow is fixed and small, raw ADB with uiautomator dump to read coordinates gets you going fastest. The moment it has to work across screen sizes or survive layout changes, move to Appium and select by element. Keep adb shell around for the device-level actions Appium doesn’t cover, and when taps matter, drive them by element or as pointer actions rather than input tap at a fixed pixel.