-
To verify if dialog appears you can simply check if View with a text that present inside the dialog is shown:
onView(withText("dialogText")).check(matches(isDisplayed()));or, based on text with id
onView(withId(R.id.myDialogTextId)).check(matches(allOf(withText(myDialogText), isDisplayed())); -
To click on dialogs button do this (button1 – OK, button2 – Cancel):
onView(withId(android.R.id.button1)).perform(click());UPDATE
- I think is possible since Espresso has multi window support.
- Not sure about clicking outside the custom dialog view but for checking if it is displaying or not you have to create your custom matcher and check inside it.