2

I have a simple monkeyrunner script opening a custom app, and I need to mark specific checkboxes in the application. So far I haven't managed to move up and down and press them using the usual:

MonkeyDevice.press("DPAD_DOWN", MonkeyDevice.DOWN_AND_UP)
MonkeyDevice.press("DPAD_CENTER", MonkeyDevice.DOWN_AND_UP)

How can I, if at all, mark a checkbox by its ID as designated by the apps xml?

Thanks in advance Noam

Yury
  • 20,618
  • 7
  • 58
  • 86
user1256607
  • 139
  • 3
  • 10

1 Answers1

2

You can give AndroidViewClient a try.

AndroidViewClient adds to monkeyrunner the ability of

  • finding Views by ID, very much like you normally do in your Android Activity (using ViewClient.findViewById())
  • obtaining the value for almost any of the Views properties (using for example View.isChecked() or View.mText())
  • sending touch events to the Views by simply invoking View.touch()

You can find a working example in monkeyrunner: interacting with the Views.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • I tried to use AndroidViewClient to send touch events on a view. But View.touch() did not touch the desired view. It touched another area. This is because the coordinates were relative to the parent. i could not figure out how to get passed this issue. I even asked a question: http://stackoverflow.com/questions/11953927/how-to-click-on-a-view-which-contains-specified-text-using-monkeyrunner-and-andr Could you please help me out? – Gabriel Porumb Sep 19 '12 at 15:07
  • Are you using the latest AndroidViewClient version? AFAIK all the cases were addressed. Should you have a test case where the latest version is failing please create an issue at https://github.com/dtmilano/AndroidViewClient/issues?sort=created&state=open – Diego Torres Milano Sep 19 '12 at 16:29