[关闭]
@act262 2017-05-24T14:20:50.000000Z 字数 1487 阅读 3186

adb shell uiautomator 命令

Android_Shell


  1. htc_himaulatt:/ $ uiautomator
  2. Usage: uiautomator <subcommand> [options]
  3. Available subcommands:
  4. help: displays help message
  5. runtest: executes UI automation tests
  6. runtest <class spec> [options]
  7. <class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> >
  8. <JARS>: a list of jar files containing test classes and dependencies. If
  9. the path is relative, it's assumed to be under /data/local/tmp. Use
  10. absolute path if the file is elsewhere. Multiple files can be
  11. specified, separated by space.
  12. <CLASSES>: a list of test class names to run, separated by comma. To
  13. a single method, use TestClass#testMethod format. The -e or -c option
  14. may be repeated. This option is not required and if not provided then
  15. all the tests in provided jars will be run automatically.
  16. options:
  17. --nohup: trap SIG_HUP, so test won't terminate even if parent process
  18. is terminated, e.g. USB is disconnected.
  19. -e debug [true|false]: wait for debugger to connect before starting.
  20. -e runner [CLASS]: use specified test runner class instead. If
  21. unspecified, framework default runner will be used.
  22. -e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
  23. May be repeated.
  24. -e outputFormat simple | -s: enabled less verbose JUnit style output.
  25. dump: creates an XML dump of current UI hierarchy
  26. dump [--verbose][file]
  27. [--compressed]: dumps compressed layout information.
  28. [file]: the location where the dumped XML should be stored, default is
  29. /sdcard/window_dump.xml
  30. events: prints out accessibility events until terminated

常用到的命令:

uiautomator dump dump出当前窗口的UI布局信息
uiautomator dump --compressed dump出当前窗口的UI布局简化信息
uiautomator dump file 指定输出文件,默认文件是在/sdcard/window_dump.xml

输出的文件可以用 sdk/tools/uiautomatorviewer.bat 工具打开查看布局

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注