I was trying to write a UiAutomator test for an application. Here I have a bunch of textviews inside relative layouts from which I want to extract text and store it in a ArrayList. So that I can compare that ArrayList to the expected result list.
Any Suggestions on how to do it?
You can iterate over all children of a RelativeLayout and get its text.
for(int i=0; i< relLayout.getChildCount(); i++) {
TextView textView = (TextView) relLayout.getChildAt(i);
String text = textView.getText().toString(); //put text in an ArrayList<String> as per your need
}
Hope this helps you.