Android Espresso: checking for a checked checkbox

General Tech Learning Aids/Tools 3 years ago

1.82K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago

I am new to Espresso at this point and I am getting this Exception:

android.support.test.espresso.AmbiguousViewMatcherException: 'with id: android:id/checkbox' matches multiple views in the hierarchy.

This happens when trying to check for a non checked box:onView(withId(android.R.id.checkbox)).check(matches(not(isChecked())));

My understanding is that I have 3 checkboxes and for some reason they all match this description, my question becomes: how can I differentiate between the checkboxes?

This is the error log that I am getting:

android.support.test.espresso.AmbiguousViewMatcherException: 'with id: android:id/checkbox' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.

View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1440, height=2560, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+->LinearLayout{id=-1, visibility=VISIBLE, width=1440, height=2392, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum