I am working on test case to my application, there is activity with tabs each tab has gridview in each gridView has some checkboxs like this image now I'm trying to scroll in gridView in first tab and select checkBox and then click on second tab and scroll and select checkBox here is my code
GridView gridView = (GridView) solo.getView("truck_points");
int gvCount = gridView.getCount();
int nColumn = gridView.getNumColumns();
int currentChilds = gridView.getChildCount();
int numOfSelectedItems = randomItem(gvCount);
int r = 14;
int index = r%nColumn;
scrollListTo(gridView, r, getInstrumentation());
ViewGroup viewGroup = (ViewGroup) gridView.getChildAt(index);
CheckBox checkBox = (CheckBox) viewGroup.getChildAt(0);
solo.clickOnView(viewGroup);
Log.e(TAG,checkBox.getText() + " item: "+ r+", index: "+index+", column: "+ nColumn);
//Click on Post-Trip
solo.clickOnView(solo.getView(android.widget.TextView.class, 9));
solo.sleep(1000);
solo.clickOnView(solo.getView("start",1));
GridView gridView1 = (GridView) solo.getView("truck_points");
int gvCount1 = gridView1.getCount();
int nColumn1 = gridView1.getNumColumns();
int currentChilds1 = gridView1.getChildCount();
int numOfSelectedItems1 = randomItem(gvCount1);
int r1 = 17;
int index1 = r1%nColumn1;
scrollListTo(gridView1, r1,getInstrumentation());
ViewGroup viewGroup1 = (ViewGroup) gridView1.getChildAt(index1);
CheckBox checkBox1 = (CheckBox) viewGroup1.getChildAt(0);
solo.clickOnView(viewGroup1);
Log.e(TAG,checkBox1.getText() + " item: "+ r1+", index: "+index1+", column: "+ nColumn1);
solo.sleep(3000);
scrollListTo method:
public <T extends AbsListView> void scrollListTo(final T listView,
final int index, Instrumentation instrumentation) {
instrumentation.runOnMainSync(new Ruable() {
@Override
public void run() {
listView.setSelection(index);
}
});
instrumentation.waitForIdleSync();
}
now in first tab it scrolling and select very well, log output:
10-05 22:41:50.786 1486-1517/? E/CheckTAG: Fifth Wheel item: 14, index: 2, column: 4
and that's right.
in tab two it's not scroll or select but view right data in log output
10-05 22:41:56.106 1486-1517/? E/CheckTAG: Front Axle item: 17, index: 1, column: 4
can any one help please??
