skillfed

uiautomator2

uiautomator for android device

uiautomator2 v3.7.0 553.5K downloads/30d#6,039 on PyPI8,268
Permissive license MIT Active released

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 uiautomator2

uv

uv add uiautomator2

poetry

poetry add uiautomator2

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

android automation pythonui testing android devicesandroid app automationxpath element interaction androidadb automation frameworkandroid device control pythonmobile ui automation
mobile-testingandroid-automationui-testing

More Testing packages