When I ran android tests on OS 8.1 emulators, I faced some ARN dialog by Google bundled apps. They led test failure related with UI, Espresso, because of the dialog remained on the UI.
To reduce the error, we can implement like below code in TestRunner.
class BaseAndroidJUnitRunner : AndroidJUnitRunner() {
override fun onStart() {
closeAppIfGoogleAppShowsARN()
super.onStart()
}
private fun closeAppIfGoogleAppShowsARN() {
val uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
uiDevice.findObject(By.res("android:id/aerr_close"))?.let {
it.click()
uiDevice.wait(Until.gone(By.res("android:id/aerr_close")), 500)
}
uiDevice.findObject(By.res("android:id/aerr_mute"))?.let {
it.click()
uiDevice.wait(Until.gone(By.res("android:id/aerr_mute")), 500)
}
}
}
https://github.com/KazuCocoa/EspressoEnv/pull/8/files
If the dialog appears before running tests, we can close it.
I could see the id resource over OS 7.0. So, We probably should implement another way for under OS 7.0. But i haven’t seen the dialog under 7.0 recently.