Issue
I create dynamic fields in my class. And I cannot to write EditTexts in layout (.xml), so I have not R.id.edit_text
, How Can to test edit text without R.id.edit_text in Espresso 2? If I have R.id.edit_text - I can write onView(withId(R.id.edit_text)).perform(typeText("123"));
But I have not the R.id.edit_text
.
Solution
withId
is only one of view matchers. You could you use others that are suitable for you case. You could check under ViewMatchers
of com.google.android.apps.common.testing.ui.espresso.matcher
.
Google code could be found here.
Also hamcrest matchers could help to have more complex conditions.
One of samples could be this:
onView(allOf(
isAssignableFrom("class name"),
withText("Text to match")))
.perform(...);
You could also write your own matcher if you need more complex one.
I am recommending also to read the Espresso documentation.
Answered By - Anna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.