For listViews you can use following method solo.getCurrentListViews()
which return a number of list views on the current screen, and then iterate through or get other object types (android widgets) from them for example you need to click image views from all lists on the screen which not redirect you to another activity and only change state of other objects:
ArrayList<ListView> lw = solo.getCurrentListViews(); // get all list views
// logging to logcat
Log.i("stats", "number of list views on the current screen: " + aLw.size());
if (aLw.size() != 0)
for (ListView l: aLw) {
// Take all image views from list and click each
ArrayList <ImageView> aIw = solo.getCurrentImageViews(l);
Log.i("stats", "list view " + l + " contains " + iw.size() + " image views.");
if (aIw.size() != 0)
for (int i = 0; i < aIw.size(); ) {
// clicking
solo.clickOnView(aIw.get(i));
Log.i("click", "image view " + i " clicked.");
}
}
You can type text to editText view or get text from textViews.
You can combine Robotium with Java and Android API. For example check visibility of images on the screen using getVisibility() method and comparing it with three major states View.GONE, View.VISIBLE, View.INVISIBLE. Or you can check connection using Java method HttpURLrequest before execution of your tests.
If you have source you can take objects from any layout knowing its ID! Also exist a lot of awesome stuff like solo.waitForActivity()
, solo.assertMemoryNotLow()
, solo.takeScreenShot()
.
More examples about Robotium usage you can find here by joining Robotium community.