Well, I figured it out myself. From this very good tutorial by Colin Miller (@LinkedIn software development engineer), I can solve it.
https://www.youtube.com/watch?v=UEklodQTJZY
This question may not be very helpful, but this tutorial is definitely useful.
The solution to this problem:
button.performClick()
XDialogFragment dialog = (XDialogFragment) activity
.getFragmentManager().findFragmentByTag(XDialogFragment.TAG);
Assert.assertNotNull(dialog);
source
share