Issue
I have a search view, when I type "Example" as the key word, it will show me a drop down suggestion list which contains 2 items with text "Example". I mean for some reason the suggestion list has 2 item with the same name.
When I do following code:
onView(withText("Example"))
.inRoot(withDecorView(not(is(mActivityRuleSaves.getActivity().getWindow().getDecorView()))))
.perform(click());
it will give me the exception, the ambiguous view since there are 2 item in the list has the name "Example".
So my question is how can I choose and click the first one?
Solution
Hope you figured out already? If not, then I use onData
instead of onView
:
onData(anything()).atPosition(0).check(matches(hasDescendant(withText(("Blah")))));
onData(anything()).atPosition(1).check(matches(hasDescendant(withText("Blah")))).perform(click());
Hope this helps.
Answered By - Arpita Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.