Android 我能';不要用浓缩咖啡点击复选框
我正在用浓缩咖啡做一些测试。我想点击复选框并用test选中它。但我不能。我试着用ıd和contentdescription。Espresso找到了视图,但无法执行Android 我能';不要用浓缩咖啡点击复选框,android,android-testing,android-espresso,Android,Android Testing,Android Espresso,我正在用浓缩咖啡做一些测试。我想点击复选框并用test选中它。但我不能。我试着用ıd和contentdescription。Espresso找到了视图,但无法执行 onView(withContentDescription("register check box 1")) .check(matches(isNotChecked())) .perform(click())
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”。我把它取下来,效果很好。但是我不明白原因。你可以回答你自己的问题。请发布一个答案,然后接受它。因为你的解决方案不容易看到。谢谢