It is possible to test view below a progress dialog, using espresso?

Viewed 664

I am trying use a function to check consistency of the activity graphic elements at any time. I found out that when the progressdialog is showing the espresso can't find any view bellow. Is there any way get the view bellow?

2 Answers

Yes, you use a RootMatcher. For example:

// Specifically target the main window view hierarchy
onView(withId(R.id.view_to_match))
    .inRoot(withDecorView(is(getActivity().getWindow().getDecorView())))
    .perform(click());

Or maybe:

// Specifically disregard the dialog window view hierarchy
onView(withId(R.id.view_to_match))
    .inRoot(not(isDialog()))
    .perform(click());

See the official documentation for an example.

Hope that helps!

Related