We currently have an Android application that we are testing with Espresso. One of the features we want to test is selecting a picture/image from the local image gallery. We can get all the way to bringing up the Gallery view, but then cannot select from Recent, Downloads, Gallery in the resulting window. A snippet as to how we got as far as we did is included below.
public void testShouldBeAbleToSelectPhotoFromGallery() {
getActivity();
// given
onView(withId(launch_gallery_button)).perform(click());
onView(withText("Gallery")).perform(click()); // this is a button in our app
// then we get stuck :(
}
Thanks!
This is not possible with with either Robotium or Espresso, as they only work on Activities of the app under test.
To write integration tests that work across different apps and Android built-in apps, you can use the UiAutomator framework provided by Google.
Basically you would analyse the gallery app in the uiautomatorview to learn how to select the ui elements your test case needs and then act on them, not unlike Espresso.
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