慕妹3242003
使用adb shell uiautomator dump命令:Usage: uiautomator <subcommand> [options]Available subcommands:help: displays help messageruntest: 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 /storage/emulated/legacy/window_dump.xmlevents: prints out accessibility events until terminated默认情况下,它会将视图层次结构转储到 $EXTERNAL_STORAGE/window_dump.xmladb shell uiautomator dumpUI hierchary dumped to: /sdcard/window_dump.xml通常,您可能希望将该文件提取到PC进行进一步处理,这将是一个额外的步骤。但是有一个巧妙的技巧,它允许将转储和拉入组合成一个命令。使用/dev/tty转储目标将生成一个命令,将整个转储打印到stdout:adb exec-out uiautomator dump /dev/tty<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><hierarchy rotation="0"><node ...></node></hierarchy>UI hierchary dumped to: /dev/tty