2016-04-05 81 views
2

我正在用濃咖啡寫一些測試。我想點擊複選框並通過測試進行檢查。但我不能。我試着用ıd和contentdescription。濃咖啡發現意見,但不能執行。我無法點擊濃咖啡複選框

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) 
+1

你可以回答你自己的問題。請發佈答案,然後接受它。因爲你的解決方案不容易看到。謝謝。 –

+0

好吧我會做到的。 –

回答

0

我找到了解決方案。在我看來,xml複選框具有該行android:layout_marginLeft =「 - 5dp」。我刪除它,並完美的作品。但我不明白原因。