由于我在注册屏幕上有几个字段,并且我对空字段使用相同的字符串资源,我该如何解决此错误?
com.som.android.acceptanceTests.signIn.RegistrationScreenTest > startRegistrationWithEmptyFields[emu_19_WXGA720(AVD) - 5.0.2] FAILED
android.support.test.espresso.AmbiguousViewMatcherException: '(with id: com.fentury.android:id/errorMessage and with text: is "This field cannot be empty")' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
答案 0 :(得分:1)
这是Espresso匹配器的绝佳资源:https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/
看起来您需要以下内容:
onView(allOf(withId(R.id.errorMessage), withSibling(withId(id for particular input))))
或isDescendantOfA()
如果它有唯一的容器视图