Issue
I have a test case of Espresso where I check for with the first line whether the dialog is displayed or not
onView(withText(R.string.dialog_title)).check(matches(isDisplayed()));
and them I perform a click on the button to close the dialog:
onView(withText(R.string.negative_button)).perform(click());
The thing is that the click operation always gets executed before check operation, because both operations are executed asynchronously. How to avoid of this problem and keep the order of the executed lines as it is written in the test case, when I don't need to perform the operations asynchronously?
Solution
You may try to customize an IdlingResource class which will wait for a certain condition until the View components will be loaded completely and only then continue the checks or perform the operations. Override isIdleNow method which should return true only when the view is loaded already (or some other condition that you need to satisfy).
Answered By - Taron Martirosyan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.