How to avoid lock screen event during monkey test

1.3k views Asked by At

i am running monkey tests and i am facing issues with lock screen.

i have tried running tests with default command as below

"monkey -p com.xyz -v 1500000 -s 10000 --throttle 15000"

The tests start fine but eventually get to lock screen and thereby never able to unlock as i have alphanumeric key code as password which is very hard to guess by random events of monkey. i just want the monkey to run only on app and ignore the lock screen events completely

i am enabling Never go to sleep from settings, please let me know if i can avoid monkey to stop pressing the power key.

1

There are 1 answers

0
piobab On BEST ANSWER

You should write your own python script. Please take a look at a simple monkeyrunner program from Android doc and an example from this tutorial. When you write the sript don't use these types of events:

device.press('KEYCODE_POWER', 'DOWN_AND_UP')
device.press('KEYCODE_POWER', 'DOWN')
device.press('KEYCODE_POWER', 'UP')

which are reponsible for screen lock (more key codes). In order to run your own script use:

mokeyrunner srcipt_name.py

Another solution could be avoiding s (pseudo-random number generator) flag in adb shell monkey command. Then use interesting flags except for --pct-syskeys (These are keys that are generally reserved for use by the system, such as Home, Back, Start Call, End Call, or Volume controls.) More flags you find in http://developer.android.com/tools/help/monkey.html