uiautomator2
uiautomator for android device
What it is and what it does
uiautomator2 is a Python automation framework for Android devices that bridges the gap between UiAutomator (Android's native testing framework) and Python code. It works by running an HTTP service on the Android device side and communicating with it from Python, exposing device capabilities like UI element selection, app launching, screen interaction, and device state queries through a simple Python API.
The package is primarily used for test automation and app control workflows. You connect to an Android device via adb, then interact with UI elements using XPath queries, UiAutomator selectors, or direct coordinate-based actions. It supports waiting for elements, retrieving text, setting input, taking screenshots, and managing device state (screen on/off, clipboard, etc.). The framework handles the complexity of the underlying UiAutomator protocol, letting you write straightforward Python scripts for mobile testing and automation.
Use it for:
- Automated UI testing of Android apps by scripting interactions with UI elements and verifying app behavior.
- Mobile app regression testing in CI/CD pipelines by running test suites against connected devices or emulators.
- Extracting data from Android apps by automating navigation and text retrieval from UI elements.
- End-to-end testing workflows that require coordinating multiple app interactions and state checks.
- Device automation tasks like app installation verification, settings configuration, or repetitive user workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automates Android device interactions from Python by exposing UiAutomator capabilities through HTTP, enabling UI testing, app control, and element manipulation via XPath queries.
Yes. The package is actively maintained, has low install friction, carries no known vulnerabilities, and uses a permissive MIT license. It fills a clear need for Python-based Android automation. Install it if you need to automate Android UI testing or device interaction from Python; the main prerequisite is having a connected Android device with developer mode enabled.
Install
uiautomator2 on PyPI
pip
pip install uiautomator2uv
uv add uiautomator2poetry
poetry add uiautomator2Installing uiautomator2
Before you install
Low install friction with a pure-Python wheel distribution. Actively maintained with recent commits and a stable release cycle; supports Python 3.8 through 3.13. Requires a connected Android device with Developer options enabled and adb access.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely as long as you include the original license notice.
Quickstart
pip install uiautomator2
import uiautomator2 as u2
d = u2.connect() # Connect to Android device
print(d.info) # Get device information
d.xpath('//*[@text="Settings"]').click() # Click element by XPath
Requires a connected Android device with Developer options enabled, adb installed and configured, and Android version 4.4 or higher.
Verify before relying
- Whether the package handles multiple simultaneous device connections or only one at a time.
- Performance characteristics when interacting with complex UI hierarchies or large numbers of elements.
- Whether network latency between the Python client and device significantly impacts automation speed.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — Pillow, adbutils, click, importlib-resources, lxml, requests, retry2 |
| Maintenance | actively maintained — 49 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 553,487/month — #6,039 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: uiautomator2-3.7.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
androidtvremote2A Python library for controlling Android TV…
permissive · top 15,000 on PyPI
uiautomatorPython wrapper for Android's uiautomator…
permissive · top 15,000 on PyPI
python-fullykioskProvides a Python interface to the Fully Kiosk…
permissive · top 15,000 on PyPI
facebook-wdaPython client library for controlling iOS…
permissive · top 15,000 on PyPI
adb-shellImplements ADB (Android Debug Bridge) shell and…
permissive · top 15,000 on PyPI
robotframework-appiumlibraryAppiumLibrary is a Robot Framework library that…
permissive · top 15,000 on PyPI
adbutilsadbutils is a Python library that communicates…
permissive · top 15,000 on PyPI
pure-python-adbPure-Python ADB client that communicates with…
permissive · top 15,000 on PyPI
requestiumRequestium merges Requests, Selenium, and…
permissive · top 15,000 on PyPI
mozdeviceManages and controls connected mobile devices…
copyleft · top 15,000 on PyPI