android - Espresso, scroll to bottom of dynamical loading ListView -
normaly scrolling down within testcase use peace of code:
onview( withid( r.id.button)).perform( scrollto(), click());
however in test want scroll down listview, childelements loaded dynamically (i dont know how many there are), when view scrolled down. there scroll bottom in espresso in robotium?
my workarround:
int [] childcount = getlistelements(); for(int = 0;i<childcount[0];i++) { ondata(anything()).inadapterview(withid(r.id.scheduleorderlistviewlistview)).atposition(i).perform(click()); childcount = getlistelements(); }
with
public int[] getlistelements(){ final int[] counts = new int[1]; onview(withid(r.id.scheduleorderlistviewlistview)).check(matches(new typesafematcher<view>() { @override public boolean matchessafely(view view) { listview listview = (listview) view; counts[0] = listview.getcount(); return true; } @override public void describeto(description description) { } })); return counts;
you should use ondata()
interact listview elements. if want scroll bottom, scroll last item. example:
ondata(instanceof(listdata.class)) .atposition(initial_list_size - 1) .perform(scrollto());
Comments
Post a Comment