Issue
When a certain EditTextView reaches 6 characters I'm using a TextWatcher to trigger a request. How do I emulate this on Espresso UI tests? I have only found examples with .perform(click()) and things like that but there is no button to trigger an action. Is there something like when number of characters reach n?
Solution
Instead of just doing .perform(click()) you should be also calling .perform(typetext()) to check what should happen when the typed characters change:
onView(withId(R.id.yourInputId)).perform(click(), typeText("123456"));
And then evaluate whatever should happen in UI after that number of characters has been reached.
P.S.: The click() before the typeText() was only needed in some old versions of espresso. I use it just in case. Sometimes more methods are needed like: perform(scrollTo(), click(), clearText(), typeText("123456")) in case a scroll is needed and the text should be cleared before setting the new text.
Answered By - jeprubio
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.