0

I'm automating the entry of SQLite data in an Android app I'm writing. The app is written in Java. The functional ui test is written in python using MonkeyRunner and is being run against the Android 4.2 emulator running on my Win7 laptop.

#Touch the new alliance button
device.touch(358, 78, 'DOWN_AND_UP')
MonkeyRunner.sleep(3)
# Type name of new alliance
device.type("Legion of Anarchy")
MonkeyRunner.sleep(3)
#Touch the allc leader edittext
device.touch(88, 348, 'DOWN_AND_UP')
# Type name of alliance leader
device.type("DeathAngel")

In the form the first field already has the focus, so i just type in the entry. The next touch command taps on the following field, but that doesn't always work. From my laptop keyboard I'm able to TAB to the next field...I just need to know how to do that in python/MonkeyRunner.

Thanks!

Quasaur
  • 1,335
  • 1
  • 10
  • 27

1 Answers1

2

If you can TAB from you keyboard, you should be able to TAB from monkeyrunner too:

device.press('KEYCODE_TAB', MonkeyDevice.DOWN_AND_UP)

however, it's probably much easier to use AndroidViewClient and do something like:

vc = ViewClient(*ViewClient.connectToDeviceOrExit())
newAlliance = vc.findViewByIdOrRaise('id/new_alliance')
newAlliance.type('Legion of Anarchy')
allianceLeader = vc.findViewByIdOrRaise('id/alliance_leader')
allianceLeader.type('DeathAngel')

and you don't have to worry about screen coordinates and other stuff. See the examples and you'll find a lot of ideas.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Thank you! I remember seeing the word AndroidViewClient somewhere but didn't realize it was capable of that! – Quasaur Feb 25 '13 at 01:53