Issue
In the app I am working on, there is a button that will open the Google Play Store page of the app. With Espresso, I want to check if the correct page is opened.
// this is the code I already have
onView(withId(R.id.SettingsButton)).perform(click());
onView(withId(R.id.RateAppButton)).perform(scrollTo(),click());
// now the Play Store should be opened (like a popup)
Now I want to find out if the displayed app title includes the correct app name and if it is an actual play store page. Since Espresso somewhat doesn't interact with the buttons in this view, what options do I have? How can I work with this new view?
Solution
As you mentioned correctly, espresso can just interact with your own package. To interact with other apps or the android system UI (e.g. permission dialogs) you have to use ui-automator.
ui-automator works well if you combine it with espresso, you can just open the playstore link in your app with espresso and then check the new screen with ui-automator (and also press the system back button to return to your app).
You could for example use something like this to check if the correct title appears:
UiObject titleLabel = mDevice.findObject(new UiSelector().text("Your Title"));
if(!titleLabel.exists())
{
throw new RuntimeException("wrong title!");
}
See this blogpost for a longer example.
Answered By - stamanuel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.