我有一个多显示场景,我想最后用Appium来测试一下。然而,现在我已经在 UiAutomatorViewer 上苦苦挣扎了。
这是我的场景:
我不知道如何访问辅助显示器。在完美的方法中,我基本上能够识别所有显示器上的所有应用程序。这有可能吗?
此外,我需要测试多个应用程序。因为像 Espresso 这样的单一应用程序方法不适合我。
根据源代码,UI automator查看器转储活动窗口的视图层次结构,屏幕截图是默认显示的屏幕截图。
如果您想使用 ui automator 查看器并分析正确的屏幕截图(以及相应的 UI 层次结构),可能的解决方法是以编程方式创建这两个文件并将它们提供给 ui automator 查看器:
adb shell am start com.google.android.calendar --display 0
adb shell screencap -d 0 -p /sdcard/screencapture0.png
adb pull /sdcard/screencapture0.png .
adb shell uiautomator dump
adb pull /sdcard/window_dump.xml
mv window_dump.xml window_dump0.uix
现在您可以在 ui automator 查看器上选择“打开”,然后选择
screencapture0.png
和 window_dump0.uix
。
通过在辅助显示屏上打开应用程序,焦点将移至另一个显示屏,您可以重新调用相同的命令来获取 2 个文件:
adb shell am start com.google.android.calendar --display 1
adb shell screencap -d 1 -p /sdcard/screencapture1.png
adb pull /sdcard/screencapture1.png .
adb shell uiautomator dump
adb pull /sdcard/window_dump.xml
mv window_dump.xml window_dump1.uix
这次提供给 ui automator 查看器的文件是
screencapture1.png
和 window_dump1.uix
。
不确定是否可以利用相同的方法来针对特定屏幕执行测试。
我在具有多个显示器(默认显示器、显示器 1 和显示器 2)的模拟器上遇到同样的问题。使用 appium 检查元素,它会看到显示 2 的元素而不是默认显示。有没有办法改变模拟器的多重显示的焦点?命令“adb shell am display move-stack 0”对我来说永远不起作用。我希望有人能在这里提供帮助。