Issue
How to test the text in the middle is ON or OFF with Espresso?
Tried the below ways but didn't work. Also facing this problem
androidx.test.espresso.AmbiguousViewMatcherException: matches multiple views in the hierarchy.. as there are multiple On/Off text visible with the same ID.
1 onView(withText("Lights")).check(isLeftAlignedWith(withText("On")))
2 onData(allOf(`is`(instanceOf(Adapter::class.java)), `is`("Lights"))).check( hasSibling(withText("On")))
Solution
You can refer to the official documentation
Instead of using the onView() method, start your search with onData() and provide a matcher against the data that is backing the view you’d like to match. Espresso will do all the work of finding the row in the Adapter object and making the item visible in the viewport.
Answered By - Monster Brain

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.