I'm trying to write some tests with the new android-test-kit (Espresso). But I can't find any information on how to check if a dialog is displayed and perform some actions on it (like clicking the positive and negative buttons, e.t.c.). Note that a dialog may be also displayed by a
To verify if dialog appears you can simply check if View with a text that present inside the dialog is shown:
or, based on text with id
To click on dialogs button do this (button1 - OK, button2 - Cancel):
I think it is possible now with latest Espresso release 1.1 - they announced multi window support.