Testing autocomplete textview using espresso tool

限于喜欢 提交于 2019-12-10 18:56:03

问题


I have an autocomplete textview and I am setting an Adapter view on it to show the list of suggestions. While testing on espresso, I want to select an item position from list of suggestions but, it does not identify the auto complete text view adapter on espresso.

I tried this answer from Stack overflow: DropDown value selection using espresso android with dynamic element id's

But, this did not work for me. Any help on this would be great. Thanks.


回答1:


or you can try instead onData. Because onData not working for me

 onView(withText("Your field name"))
.inRoot(withDecorView(not(is(getActivity().getWindow().getDecorView()))))
            .perform(click());



回答2:


I run into the same problem and this is how i did it:

onView(withId(R.id.sp_country/*auto complete textview*/)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(COUNTRY/*selected value autocomplete collection*/)))
                .inRoot(RootMatchers.withDecorView(not(is(activityActivityTestRule
                        .getActivity().getWindow().getDecorView()))))
                .perform(click());


来源:https://stackoverflow.com/questions/36284605/testing-autocomplete-textview-using-espresso-tool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!