我想转储窗口层次结构并从 gradle 管理的设备读取文件,但在写入文件时我不断遇到文件问题。它应该将其输出到目录 app/build/outputs/managed_device....
java.io.FileNotFoundException:window_dump.xml:打开失败:libcore.io.IoBridge.open处的EROFS(只读文件系统)(IoBridge.java:574)
gradle命令:
./gradlew app:phonesGroupDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.regressions.OnboardingRegressions
OnboardingRegressions.kt
...
// this finds the title but can't find and click the button
val objectTitle = device.findObject(By.textContains("to send you notifications?"))
assert(objectTitle.text.contains("to send you notifications?"))
// want to read why the Allow button is not seen,
device.dumpWindowHierarchy(File("window_dump.xml"))
// Test fails here when above line is commented out
device.findObject(By.text("Allow")).click()
...
仅供参考,测试在 IDE 中的模拟器上运行完美,但一旦我在托管设备上运行,它就无法找到该按钮。仅供参考,这是一个 API 34 设备
使用它可以在控制台视图或 logcat 中查看它。
device.dumpWindowHierarchy(System.out as OutputStream)