百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

android-uiautomator-server

> 编程语言
开源

UIAutomator 是一个非常棒的工具,可用于执行 Android UI 测试,但要使用它,您必须编写 Java 代码,编译代码,安装 jar 文件……

354 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

UIAutomator 是一个非常棒的工具,可用于执行 Android UI 测试,但要使用它,您必须编写 Java 代码,编译代码,安装 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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaapkuiautomator

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

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