Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

android-uiautomator-server

> 编程语言
Open source

Purpose UIAutomator is a great tool to perform Android UI testing, but to do it, you have to write java code, compile it, install the jar, …

354 stars0 likes2 views
WebsiteGitHub

About

Purpose UIAutomator is a great tool to perform Android UI testing, but to do it, you have to write java code, compile it, install the jar, …

Purpose

UIAutomator is a great tool to perform Android UI testing, but to do it, you have to write java code, compile it, install the jar, and run. It's a complex steps for all testers...

This project is to build a light weight jsonrpc server in Android device, so that we can just write PC side script to write UIAutomator tests.

Build

  • Run command:
bash
$ ./gradlew build
$ ./gradlew packageDebugAndroidTest
  • Run the jsonrpc server on Android device
bash
$ ./gradlew cC
$ adb forward tcp:9008 tcp:9008 # tcp forward

If debug apk already installed, There is no need to use gradle.

simply run the following command

bash
adb forward tcp:9008 tcp:9008
adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub \
    com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner

Run

bash
$ curl -X POST -d '{"jsonrpc": "2.0", "id": "1f0f2655716023254ed2b57ba4198815", "method": "deviceInfo", "params": {}}' 'http://127.0.0.1:9008/jsonrpc/0'
{'currentPackageName': 'com.smartisanos.launcher',
 'displayHeight': 1920,
 'displayRotation': 0,
 'displaySizeDpX': 360,
 'displaySizeDpY': 640,
 'displayWidth': 1080,
 'productName': 'surabaya',
 'screenOn': True,
 'sdkInt': 23,
 'naturalOrientation': True}

Resources

  • Google UiAutomator Tutorial
  • Google UiAutomator API
  • Maven repository of uiautomator
  • androidx.test.uiautomator release notes

Clipboard, Thanks to @fplust

  • https://github.com/majido/clipper
  • https://github.com/appium/io.appium.settings/blob/5d3bc99ff35f3b816b4342395aba1bdea82ad48f/app/src/main/java/io/appium/settings/receivers/ClipboardReceiver.java

The buildin input method

com.github.uiautomator/.AdbKeyboard

Encode the text into UTF-8 and then Base64

For example:

"Hello 你好" -> (UTF-8 && Base64) = SGVsbG8g5L2g5aW9

Send to AdbKeyboard with broadcast

Broadcast completed: result=-1 means success

…
  • Editor Code
  • Key Event

Change GPS mock location

You can change mock location from terminal using adb in order to test GPS on real devices.

adb [-s ] shell am broadcast -a send.mock [-e lat ] [-e lon ]
        [-e alt ] [-e accurate ]

For example:

adb  shell am broadcast -a send.mock -e lat 15.3 -e lon 99

Show toast

adb shell am start -n com.github.uiautomator/.ToastActivity -e message hello

Float window

adb shell am start -n com.github.uiautomator/.ToastActivity -e showFloatWindow true # show
adb shell am start -n com.github.uiautomator/.ToastActivity -e showFloatWindow false # hide

How to use with Python

python
import uiautomator2 as u2

d = u2.connect()

d.screen.on()
d(text="Settings").click()
d(scrollable=True).scroll.vert.forward()

Refer to python wrapper library uiautomator.

How to generate changelog

conventional-changelog

bash
npm install -g conventional-changelog-cli
conventional-changelog -p grunt -i CHANGELOG.md -s -r 0

Notes

If you have any idea, please email [email protected] or submit tickets.

Dependencies

  • nanohttpd
  • jsonrpc4j
  • jackson
  • androidx.test.uiautomator

Added features

  • support unicode input

Thanks to

  • xiaocong
  • https://github.com/willerce/WhatsInput
  • https://github.com/senzhk/ADBKeyBoard
  • https://github.com/amotzte/android-mock-location-for-development
  • https://github.com/gladed/gradle-android-git-version

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaapkuiautomator

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言