|
| 1 | +### uiparser (MonkeyRunner is DEAD!) |
| 2 | + |
| 3 | +Setup |
| 4 | +> export ANDROID_HOME="/Users/chenqi/Library/Android/sdk" |
| 5 | +
|
| 6 | +Run |
| 7 | +> $ANDROID_HOME/tools/bin/monkeyrunner uiparser.py |
| 8 | +
|
| 9 | +### MonkeyRunner |
| 10 | +https://developer.android.google.cn/studio/test/monkeyrunner |
| 11 | + |
| 12 | +#### MonkeyDevce.shell() |
| 13 | +>object shell (string cmd) |
| 14 | +Executes an `adb` shell command and returns the result, if any. |
| 15 | + |
| 16 | +等同于调用`adb shell`命令。 |
| 17 | +https://developer.android.google.cn/studio/command-line/adb#shellcommands |
| 18 | + |
| 19 | +#### MonkeyDevice.getProperty() |
| 20 | +> object getProperty (string key) |
| 21 | +Given the name of a system environment variable, returns its value for this device. |
| 22 | + |
| 23 | +获取设备系统环境变量。 |
| 24 | +等同于调用`adb shell getprop <keyword>`。 |
| 25 | +不同厂商的设备,key可能不同。 |
| 26 | +使用`adb shell getprop`,显示所有系统环境变量的key字符串 |
| 27 | + |
| 28 | +### adb |
| 29 | +https://developer.android.google.cn/studio/command-line/adb |
| 30 | + |
| 31 | +#### adb shell am |
| 32 | +https://developer.android.google.cn/studio/command-line/adb#am |
| 33 | +使用 Activity Manager (am) 工具发出命令以执行各种系统操作,如启动 Activity、强行停止进程、广播 intent、修改设备屏幕属性及其他操作。 |
| 34 | + |
| 35 | +#### adb shell pm |
| 36 | +https://developer.android.google.cn/studio/command-line/adb#pm |
| 37 | +使用软件包管理器 Package Manager (pm) 工具发出命令,安装,卸载,查询安装包。 |
| 38 | + |
| 39 | +#### adb shell uiautomator |
| 40 | +获取当前界面的层级结构XML信息。 |
| 41 | +``` |
| 42 | +adb shell uiautomator dump /sdcard/uiparser/ui.xml |
| 43 | +adb pull /sdcard/uiparser/ui.xml ./ui.xml |
| 44 | +``` |
| 45 | +Usage: |
| 46 | +``` |
| 47 | +Usage: uiautomator <subcommand> [options] |
| 48 | +
|
| 49 | +Available subcommands: |
| 50 | +
|
| 51 | +help: displays help message |
| 52 | +
|
| 53 | +runtest: executes UI automation tests |
| 54 | + runtest <class spec> [options] |
| 55 | + <class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> > |
| 56 | + <JARS>: a list of jar files containing test classes and dependencies. If |
| 57 | + the path is relative, it's assumed to be under /data/local/tmp. Use |
| 58 | + absolute path if the file is elsewhere. Multiple files can be |
| 59 | + specified, separated by space. |
| 60 | + <CLASSES>: a list of test class names to run, separated by comma. To |
| 61 | + a single method, use TestClass#testMethod format. The -e or -c option |
| 62 | + may be repeated. This option is not required and if not provided then |
| 63 | + all the tests in provided jars will be run automatically. |
| 64 | + options: |
| 65 | + --nohup: trap SIG_HUP, so test won't terminate even if parent process |
| 66 | + is terminated, e.g. USB is disconnected. |
| 67 | + -e debug [true|false]: wait for debugger to connect before starting. |
| 68 | + -e runner [CLASS]: use specified test runner class instead. If |
| 69 | + unspecified, framework default runner will be used. |
| 70 | + -e <NAME> <VALUE>: other name-value pairs to be passed to test classes. |
| 71 | + May be repeated. |
| 72 | + -e outputFormat simple | -s: enabled less verbose JUnit style output. |
| 73 | +
|
| 74 | +dump: creates an XML dump of current UI hierarchy |
| 75 | + dump [--verbose][file] |
| 76 | + [--compressed]: dumps compressed layout information. |
| 77 | + [file]: the location where the dumped XML should be stored, default is |
| 78 | + /sdcard/window_dump.xml |
| 79 | +
|
| 80 | +events: prints out accessibility events until terminated |
| 81 | +``` |
0 commit comments