In Espresso, how to avoid AmbiguousViewMatcherException when multiple views match
You should use onData()
to operate on GridView
:
onData(withId(R.id.item_image))
.inAdapterView(withId(R.id.grid_adapter_id))
.atPosition(0)
.perform(click());
This code will click on the image inside first item in GridView
Espresso: avoid AmbiguousViewMatcherException by specifying the parent view
You could try combination of matchers with allOf
, like for example:
onView(allOf(withId(R.id.feeding_name), withParent(withId(R.id.fragment_show_feeding))))
.check(matches(isDisplayed()));
AmbiguousViewMatcherException multiple RecyclerViews
You have multiple views with id R.id.recyclerView
in your view hierarchy, therefore espresso lacks to perform correct matching. Make the id
s of those RecyclerView
s unique.
onView(allOf(withId(R.id.recyclerView), isDisplayed()))
onView(withId(R.id.recyclerView)).perform(swipeUp())
But caught error only on second line.
Then perform matching this way:
onView(allOf(withId(R.id.recyclerView), isDisplayed())).perform(swipeUp())
Espresso: matches multiple views in the hierarchy
Yes.
It seems like your assumption is correct.
The Material Lib uses an internal view called InternalEditText
.
You will need to specify an extra matcher to match the correct view.
Espresso AmbiguousViewMatcherException when trying to click a navigation button
This is not a bug in Espresso. The view hierarchy clearly shows two views having the same ID. This is likely due to the view being inside a ViewPager, which is an AdapterView. So multiple instances are to be expected.
To solve this, be more specific when matching the view. Going just by ID doesn't help. Since the other ImageView for the home button is not visible, because it's parent is GONE, you can simply match for that:
onView(allOf(withId(..), withEffectiveVisibility(VISIBLE))).perform(click());
Related Topics
Intent Putextra Arraylist<Namevaluepair>
Difference Between Addvalueeventlistener() and Addlistenerforsinglevalueevent() of Firebase
Android, Landscape Only Orientation
Query the Google Play Store for the Version of an App
Findviewbyid Returns Null When Using Fragment
Unexpected Namespace Prefix "Xmlns" Found for Tag Linearlayout
Textbox Hidden Below Keyboard in Android Webview
Android Get a Cursor Only with Contacts That Have an Email Listed >Android 2.0
How to Align Textview Around an Imageview
Android:Google Maps API Key Signup:Md5 Certification Key
How to Use Edittext Ontextchanged Event When I Press the Number
Detecting Gps On/Off Switch in Android Phones
Method to Get All Edittexts in a View
How to Get Dependencies from Jcenter with a New Project