我无法使用 Espresso 单击复选框
I can't click checkbox with Espresso
我正在用浓缩咖啡编写一些测试。我想单击复选框并通过测试对其进行检查。但我不能。我尝试了 ıd 和 contentdescription。 Espresso 找到了观看次数但无法执行。
onView(withContentDescription("register check box 1"))
.check(matches(isNotChecked()))
.perform(click())
.check(matches(isChecked()));
我收到那个错误。
android.support.test.espresso.PerformException: Error performing 'sıngle click' on view 'with content description: is "register check box 1"'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
我找到了解决方案。在我看来 xml 复选框有那一行 android:layout_marginLeft="-5dp"。我将其删除并完美运行。但是我不明白原因。
我正在用浓缩咖啡编写一些测试。我想单击复选框并通过测试对其进行检查。但我不能。我尝试了 ıd 和 contentdescription。 Espresso 找到了观看次数但无法执行。
onView(withContentDescription("register check box 1"))
.check(matches(isNotChecked()))
.perform(click())
.check(matches(isChecked()));
我收到那个错误。
android.support.test.espresso.PerformException: Error performing 'sıngle click' on view 'with content description: is "register check box 1"'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
我找到了解决方案。在我看来 xml 复选框有那一行 android:layout_marginLeft="-5dp"。我将其删除并完美运行。但是我不明白原因。