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 WebView
, not by the application it self.
Any help would be appreciated. I just need a link, or some example code for the basics:
- Check if a dialog appears
- Perform clicks on dialog buttons
- Interact with the dialog's inner view (if it's a custom view)
- Preform clicks outside the dialog, and check if it's displaying or not (for example if
setCancelable(false)
was called on the dialog builder and we want to check that)
Thank you in advice!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…