I am trying to test my app with Espresso.
I have a problem: in one use case, i need to open a PDF for reading "User conditions" and i can not return back from this point with Espresso.pressBack(), always i have the error below:
android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you t to launch the activity. (test.getActivity() or similar)?
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError (DefaultFailureHandler.java:88)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:51)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:173)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:114)
at android.support.test.espresso.Espresso.pressBack(Espresso.java:220)
Any suggested solution ?
Just add:
dependencies {
...
androidTestImplementation('androidx.test.uiautomator:uiautomator:$uiAutomatorVersion')
}
And then simply:
val device = UiDevice.getInstance(getInstrumentation())
device.pressBack()
This should be included in espresso I believe, no sense to have it as separate thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With