我正在用浓缩咖啡写一些测试。我想点击复选框并用测试检查它。但我不能。我尝试了ı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)
答案 0 :(得分:0)
我找到了解决方案。在我看来,xml复选框有一行android:layout_marginLeft =" -5dp"。我删除它并完美地工作。但我无法理解原因。