Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

click(id) doesn't work when multiple views in the hierarchy #68

Closed
MarinaTov opened this issue May 17, 2017 · 5 comments
Closed

click(id) doesn't work when multiple views in the hierarchy #68

MarinaTov opened this issue May 17, 2017 · 5 comments
Labels

Comments

@MarinaTov
Copy link

MarinaTov commented May 17, 2017

When I click close_button:

1495025046092

I get error android.support.test.espresso.AmbiguousViewMatcherException: 'with id: com.schibsted.android.rocket.kufar.debug:id/close_button' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below.

screen shot 2017-05-17 at 5 38 45 am

@MarinaTov MarinaTov changed the title Matches multiple views in the hierarchy click(id) doesn't work when multiple views in the hierarchy May 17, 2017
@rocboronat
Copy link
Member

Hi @MarinaTov !

It seems that Espresso is trying to express the idea that multiple Views has the ID you're trying to click. So, it doesn't know what View is the View you want to click.

To fix the issue, we have different options there:

  • Give different names to that different buttons. It's the simpler solution, and IMHO, something that improves the maintainability of the whole project. But it could be an issue if it's placed inside a RecyclerView, like your case.
  • Use BaristaRecyclerViewActions.clickRecyclerViewItemChild(R.id.user_preference_category_recycler_view, 0, R.id.close_button), that will try to tap R.id.close_button of the first child inside R.id.user_preference_category_recycler_view.
  • Update Barista to the last version (1.0.1), as it only clicks on visible items. It could be an easy fix to this scenario. But the issue will appear again when you place two childs inside the recycler with the R.id.close_button visible.

Let me keep this question open to track if the answer helps you fixing it! :·)

@MarinaTov
Copy link
Author

version 1.0.1 resolved problem
Thanks a lot

@rocboronat
Copy link
Member

You're welcome! :·)

@RajaniAchrya
Copy link

Hi, I'm getting id/phoneEditText' matches multiple views in the hierarchy. Problem views are marked with 'MATCHES' below.
where there's only one view with this id.

@ShaxGOD
Copy link

ShaxGOD commented Aug 1, 2022

How can we just interact with id ? like id/phoneEditText[0] - is that possible ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants