Android device control and test automation - Python client for the DeviceKit agent
Project description
droidlink
Android device control and test automation in Python — the client library of the DeviceKit platform. Connect to phones over USB or WiFi, drive the UI, run shell commands, manage files and apps, read metrics and notifications, and plug straight into pytest for device testing in CI.
Devices run the lightweight DeviceKit agent app (an HTTP server on the phone); droidlink talks to it directly — over USB via ADB port forwarding, or over WiFi with UDP auto-discovery. No backend server required.
Install
pip install droidlink
Quick Start
import droidlink
# Connect via USB (auto-detect)
d = droidlink.connect()
# Connect to a specific device
d = droidlink.connect("EMULATOR5554")
# Connect via WiFi (no ADB needed)
d = droidlink.connect_wifi("192.168.1.5")
# Device info
print(d.info) # model, SDK, screen size
print(d.battery) # level, charging, temperature
# UI Automation
d(text="Login").click()
d(resourceId="com.app:id/input").set_text("hello")
d(className="android.widget.EditText", instance=2).clear_text()
d(scrollable=True).scroll.to(text="Bottom Item")
if d(text="Error").exists(timeout=3):
print("Error dialog appeared")
# Screenshots
d.screenshot("screen.png")
# Shell commands
result = d.shell("whoami")
print(result.output)
# File management
files = d.files.list("/sdcard/DCIM/")
d.files.push("./config.json", "/sdcard/config.json")
d.files.pull("/sdcard/photo.jpg", "./photo.jpg")
# App management
d.app.launch("com.android.chrome")
apps = d.app.list(filter="user")
results = d.app.search("chrome")
# Notifications
notifications = d.notifications.list()
# Device metrics
metrics = d.metrics.snapshot()
print(f"CPU: {metrics.cpu_percent}%, RAM: {metrics.ram_used_mb}MB")
# Clipboard
d.clipboard.set("copied text")
print(d.clipboard.get())
CLI
droidlink devices # list connected devices
droidlink ping # check agent connectivity
droidlink info # show device info
droidlink screenshot -o s.png # take screenshot
droidlink shell "ls /sdcard" # run shell command
droidlink apps # list user apps
droidlink notifications # list notifications
droidlink metrics # show device metrics
pytest plugin
The package ships a pytest plugin with device and device_pool fixtures:
def test_login_flow(device):
device.app.launch("com.example.app")
device(text="Login").click()
assert device(text="Welcome").exists(timeout=5)
pytest tests/ --device <SERIAL> # USB device
pytest tests/ --device-wifi 192.168.1.5 # WiFi device
pytest tests/ --devicekit-url http://ci:5050 # report results to a DeviceKit backend
With --devicekit-url, test results, build lifecycle, and failure screenshots are
reported to the DeviceKit dashboard automatically.
Requirements
- Python 3.8+
- Android device with the DeviceKit agent app installed and running
- ADB (for USB connections) or WiFi connectivity
Part of DeviceKit
droidlink is the programmatic entry point to the larger DeviceKit platform: a fleet dashboard with real-time streaming, a visual automation editor with AI generation and self-healing, visual regression testing, fleet queries, and failure debug bundles.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file droidlink-0.1.0.tar.gz.
File metadata
- Download URL: droidlink-0.1.0.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2d15aa17a7fe61f36228725becabe7737c430f9c7b0ff68adc131fd7632cdf6
|
|
| MD5 |
b24ac5e23eda6c66c95431bb170897dc
|
|
| BLAKE2b-256 |
da8e10b399f9a224051bddb3d9f1db64f759cb651bf8bfacb20095072ecc06c4
|
File details
Details for the file droidlink-0.1.0-py3-none-any.whl.
File metadata
- Download URL: droidlink-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
735b7bea6ce2bb138e3568a68a5e697d4a47f8a323b4353f40e44d7757da9672
|
|
| MD5 |
1433a9e8e3332a596c6e3b7dd148417d
|
|
| BLAKE2b-256 |
e7b20e24623f82586437e8fcbd0170b418bc05e25be7bb0841dec294a35bef17
|