Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从adb shell运行UIAutomator2命令?_Android_Adb_Android Uiautomator_Uiautomatorviewer - Fatal编程技术网

Android 如何从adb shell运行UIAutomator2命令?

Android 如何从adb shell运行UIAutomator2命令?,android,adb,android-uiautomator,uiautomatorviewer,Android,Adb,Android Uiautomator,Uiautomatorviewer,可能是个愚蠢的问题,但我想验证答案是否是否定的: 在不启动插入指令的测试类的情况下,是否可以从adb shell运行UIAutomator2命令 到目前为止,我所能做的似乎只是转储XML并解析它,但我想知道是否可以调用单个命令;不,对于UiAutomator2拥有的几乎所有操作/可用方法,您不能使用adb shell uiautomator xyzcommands 运行adb shell uiautomator--help将显示可用的子命令: adb shell uiautomator --he

可能是个愚蠢的问题,但我想验证答案是否是否定的:

在不启动插入指令的测试类的情况下,是否可以从
adb shell
运行
UIAutomator2
命令


到目前为止,我所能做的似乎只是转储XML并解析它,但我想知道是否可以调用单个命令;不,对于
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

adb shell uiautomator--帮助
用法:uiautomator[选项]
可用子命令:
帮助:显示帮助消息
运行测试:执行UI自动化测试
运行测试[选项]
:<-c |-e类>
:包含测试类和依赖项的jar文件列表。如果
路径是相对的,假定在/data/local/tmp下。使用
如果文件位于其他位置,则为绝对路径。可以创建多个文件
指定的,用空格分隔的。
:要运行的测试类名称列表,以逗号分隔。到
对于单个方法,请使用TestClass#testMethod格式。-e或-c选项
可能会重复。此选项不是必需的,如果未提供,则
提供的JAR中的所有测试都将自动运行。
选项:
--nohup:陷阱SIG_HUP,所以即使父进程
已终止,例如USB已断开。
-e debug[true | false]:等待调试器连接后再启动。
-e runner[类]:改用指定的测试运行程序类。如果
未指定,将使用框架默认运行程序。
-e:传递给测试类的其他名称-值对。
可能会重复。
-e outputFormat simple |-s:启用了较少冗余的JUnit样式输出。
转储:创建当前UI层次结构的XML转储
转储[--verbose][file]
[--compressed]:转储压缩的布局信息。
[文件]:转储XML的存储位置,默认为
/sdcard/window_dump.xml
事件:打印可访问性事件,直到终止
然而,我在大多数(如果不是全部的话)adb命令中发现了这个非常有用的要点:

此外,您还可以检查运行的命令:

adb shell toybox--long | tr”“\n”

如果需要交互,请查看
adb shell sendevent

源代码如下: