[英]How to run UIAutomator2 commands from adb shell?
可能是一個愚蠢的問題,但我想驗證答案是否定的:
可以在不啟動儀器測試 class 的情況下從adb shell
運行UIAutomator2
命令嗎?
到目前為止,我似乎所能做的就是轉儲 XML 並解析它,但我想知道我是否可以調用單個命令。
TLDR; 不,對於UiAutomator2
具有的幾乎所有操作/可用方法,您不能使用adb shell uiautomator xyzcommands
。
運行adb shell uiautomator --help
將顯示可用的子命令:
adb shell uiautomator --help
Usage: uiautomator <subcommand> [options]
Available subcommands:
help: displays help message
runtest: executes UI automation tests
runtest <class spec> [options]
<class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> >
<JARS>: a list of jar files containing test classes and dependencies. If
the path is relative, it's assumed to be under /data/local/tmp. Use
absolute path if the file is elsewhere. Multiple files can be
specified, separated by space.
<CLASSES>: a list of test class names to run, separated by comma. To
a single method, use TestClass#testMethod format. The -e or -c option
may be repeated. This option is not required and if not provided then
all the tests in provided jars will be run automatically.
options:
--nohup: trap SIG_HUP, so test won't terminate even if parent process
is terminated, e.g. USB is disconnected.
-e debug [true|false]: wait for debugger to connect before starting.
-e runner [CLASS]: use specified test runner class instead. If
unspecified, framework default runner will be used.
-e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
May be repeated.
-e outputFormat simple | -s: enabled less verbose JUnit style output.
dump: creates an XML dump of current UI hierarchy
dump [--verbose][file]
[--compressed]: dumps compressed layout information.
[file]: the location where the dumped XML should be stored, default is
/sdcard/window_dump.xml
events: prints out accessibility events until terminated
但是我發現這個非常有用的 Gist 與大多數(如果不是全部) adb
命令: https://gist.github.com/Pulimet/5013acf2cd5b28e55036c82c91bd56d8
您還可以檢查自己可以運行哪些命令:
adb shell toybox --long | tr " " "\n"
如果您需要交互,請查看adb shell sendevent
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.