swagatika
swagatika

Reputation: 31

Example for using monkey command with almost all options in android

I started to learn adb shell monkey command for testing an Android app through develoers.android.com website. However, I was able to figure out example for options v and s (seed). I need to use other options to control the touch inputs to the app with available options. I searched for examples/samples/guide to use the command in full fledge, resulted in none. If any of the developers is aware of using the command with all the options, please let me know.

Google search says,

adb shell monkey -p <package_name> -v n -s SEED

I am trying to figure out how to use -s option to control touch inputs. Any help or direction to know this will help me a lot.

Upvotes: 2

Views: 25073

Answers (2)

Grant
Grant

Reputation: 75

The -s option simply provides a seed to the pseudo-random generator. This is useful when you want to replicate random events, but it is not useful for specifying specific events.

There is a rather hacky way to provide touch events directly to monkey.

Monkey provides the --port option as used in:

adb shell monkey --port 1080

This will create a TCP socket on 1080. You can connect to the port with telnet and directly tell monkey what to do.

Note: you can use:adb forward tcp:1080 tcp:1080 to forward the port to your computer.

You can connect to that port via telnet with Putty on Windows or, in Linux, run telnet localhost 1080

You can use the command tap x y to send the x and y coordinate where you want to tap. For example, tap 100 200 will tap the screen at (100,200).

Here are more examples for the API used by monkey (Not my code)

Upvotes: 2

Thupten
Thupten

Reputation: 2218

If you want to control where to click on the screen then you need monkeyrunner. monkeyrunner is an api not a command. You can create a python script or java program to automate series of events.

http://developer.android.com/tools/help/monkeyrunner_concepts.html

With monkey command, you can increase the probability of certain events with percent value.

adb shell monkey -p your.package.name --pct-appswitch 75 -v 500

--pct-syskeys Adjust percentage of "system" key events. (These are keys that are generally reserved for use by the system, such as Home, Back, Start Call, End Call, or Volume controls.) More options at http://developer.android.com/tools/help/monkey.html

Upvotes: 7

Related Questions