My goal is to make a monkey visit all pages/activity of a given android application.
I am currently using Chimpchat and my first steps are as following :
1 - Connection to the device :
TreeMap<String, String> options = new TreeMap<String, String>();
options.put("backend", "adb");
options.put("adbLocation", ADB);
mChimpchat = ChimpChat.getInstance(options);
mDevice = mChimpchat.waitForConnection(TIMEOUT, ".*");
mDevice.wake();
2 - Getting a list of view IDs :
mDevice.getViewIdList();
3 - For each strings (using iterator it) ID contains in list returned by getViewIdList(), I would like to access Class, Text if any, bounds, etc ...
while (it.hasNext()) {
String s = it.next();
System.out.println(s + " : ");
try {
IChimpView v = mDevice.getView(By.id(s));
System.out.println(v);
System.out.println(v.getViewClass() + " : " );
if (v.getViewClass().toString() == "TextView") {
System.out.print(v.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
}
I get an exception on the
v.getViewClass()
com.android.chimpchat.core.ChimpException: Node with given ID does not exist
at com.android.chimpchat.ChimpManager.queryView(ChimpManager.java:415)
at com.android.chimpchat.core.ChimpView.queryView(ChimpView.java:53)
at com.android.chimpchat.core.ChimpView.getViewClass(ChimpView.java:96)
at JavaMonkey.listViewsID(JavaMonkey.java:80)
at JavaMonkey.main(JavaMonkey.java:114)
If anyone can point my mistake(s) or point me to another approach, it would be greatly appreciated !