Android Gradle Managed Device Test Fails Need to Read WindowHierarchy

16 Views Asked by At

I want to dump the window hierarchy and read from the gradle managed device the file but I keep getting File issues with writing it. It should output it to the directory app/build/outputs/managed_device....

java.io.FileNotFoundException: window_dump.xml: open failed: EROFS (Read-only file system) at libcore.io.IoBridge.open(IoBridge.java:574)

gradle command:

./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()
...

FYI the test runs perfect on emulator in the IDE but as soon as I run on managed device it can't locate the button. FYI this is a API 34 device

0

There are 0 best solutions below