java - 下面的比赛在 Espresso

标签 java android android-espresso

由于我在注册屏幕上有多个字段,并且我对空字段使用相同的字符串资源,我该如何解决这个错误?

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.

最佳答案

这是 Espresso 匹配器的重要资源:https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/

看起来您需要以下内容: onView(allOf(withId(R.id.errorMessage), withSibling(withId(特定输入的 id))))

isDescendantOfA()是否有一个独特的容器 View

关于java - 下面的比赛在 Espresso ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43606649/

相关文章:

java - Android - java.net.ConnectException : failed to connect - connect failed: EMFILE (Too many open files)

java - 带有嵌入式 Jetty 服务器的 REST 资源

android - 在 Android 中裁剪图像的 ImageView 缩放类型

android - 使用 HTML 内容在 TextView 上进行额外填充

android - 使用 Espresso 测试包含的 View

java - Maven:在尝试在线之前如何配置为使用本地存在的 Artifact (~/.m2/repository)?

java - 如何在liferay中制作自定义应用程序显示模板

android - 获取数据库时出现无效的 Firebase 路径错误

android - ActivityTestRule 和 IntentTestRule 有什么区别

kotlin - 无法加载AndroidJUnit4的代表赛跑者 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner'