Questions tagged [monkeyrunner]

Monkeyrunner is tool from Android SDK which provides an API for writing programs that control an Android device or emulator from outside of Android code.

Monkeyrunner is a host side application to control a monkey instance on a device.
Monkeyrunner provides some useful helper functions to control the device as well as various other methods to help script tests.

The monkeyrunner tool provides an API for writing programs that control an Android device or emulator from outside of Android code.
With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation.

The monkeyrunner tool is primarily designed to test applications and devices at the functional/framework level and for running unit test suites, but you are free to use it for other purposes.

476 questions
15
votes
1 answer

What exactly is a monkey doing messing with my Android phone?

Looking through the Android apis I found a method call isUserAMonkey(), says it returns true if the phone is being messed with by a monkey. Is this a joke, or what is it used for?
MattoTodd
  • 14,467
  • 16
  • 59
  • 76
13
votes
4 answers

How can I make a Java app using the Monkeyrunner API?

The Android SDK has an API for sending commands to the phone called Monkeyrunner. It appears to be a Python API. Is there anyway I can use it in a Java application?
Matt R. Johnson
  • 783
  • 1
  • 7
  • 14
13
votes
4 answers

How to use monkey and monkeyrunner tools for android testing?

How do you use monkey and monkeyrunner tools for android testing? What are the basic commands needed?
Terminator
  • 227
  • 1
  • 2
  • 5
12
votes
5 answers

How to get the Android ID for a menu item in Android?

Is there a way to get the Android ID for a menu item? I can see getTitle() but not a getId(). I'm interested in the ID value "menu_printer_settings" rather than the title value "printer_settings" and the menu item ID (getItemId()). I need this ID to…
AndroidDev
  • 5,193
  • 5
  • 37
  • 68
10
votes
1 answer

Importing MonkeyRunner into Python script fails in Windows

Why importing MonkeyRunner into Python script fails in Windows? I created a file foo.py and copy-pasted code from the MonkeyRunner docs. The following error appears when compiling the sample code in cmd line: Traceback (most recent call last): …
Jarno Argillander
  • 5,885
  • 2
  • 31
  • 33
10
votes
6 answers

android monkey runner scripts

i am tryig to execute a sample python program through monkey runner command prompt and it is throwing an error Can't open specified script file Usage: monkeyrunner [options] SCRIPT_FILE -s MonkeyServer IP Address. -p MonkeyServer…
saibabu
  • 131
  • 1
  • 1
  • 4
10
votes
3 answers

How to click a view of android program through MonkeyRunner?

I want to use MonkeyRunner to test the compatibility of my android program for a list of devices with different screen resolutions. I need to click a view, but the view is not in the same position for different resolutions. How can I get the…
Yingyi Xu
  • 387
  • 1
  • 3
  • 15
9
votes
7 answers

MonkeyRunner: easy way to determine coordinates for MonkeyDevice touch command?

I've started creating a MonkeyRunner script. This is going ok, but whenever I add a MonkeyDevice::touch command, I have to determine the input coordinates by trial-and-error. Basically I guess at the coordinates I want to touch and see if those…
ndnfan
  • 161
  • 1
  • 6
9
votes
3 answers

Switch language programmatically on an Android device

I'm writing some Android test automation for our applications, which are localized into 18 languages. I need the ability to switch the language on the device programmatically - I don't mean to switch the language of just the application - I mean…
Jimmy Collins
  • 3,294
  • 5
  • 39
  • 57
9
votes
5 answers

Where is the help.py for Android's monkeyrunner

I just can't find the help.py file in order to create the API reference for the monkeyrunner. The command described at the Android references monkeyrunner help.py does not work when i call monkeyrunner html help.py…
Ben Weiss
  • 17,182
  • 6
  • 67
  • 87
8
votes
2 answers

How to inherit from MonkeyDevice?

I would like to extend the MonkeyDevice class of the monkeyrunner API. My derived class looks like this. from com.android.monkeyrunner import MonkeyDevice, MonkeyRunner class TestDevice(MonkeyDevice): def __init__(self, serial=None): …
Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
8
votes
1 answer

control android device/emulator by python

I am not familiar with android development. But just want to use python script to do something on my android device/emulator. For example: change system settings. set a proxy. open app A, click some place, do something else... then open app B, tap…
Mithril
  • 12,947
  • 18
  • 102
  • 153
8
votes
2 answers

How to tell if screen is on with ADB

I am looking to find out whether or not it is possible to determine if the screen is on on an android device using ADB. I need to know this for some tests I am trying to run using monkey runner. Is there a shell command I can enter, and thus include…
Andrew T.
  • 4,598
  • 4
  • 35
  • 54
7
votes
0 answers

The events generated by Android's Monkey are not the same when the seed is the same

I use the Monkey to stress-test my app. On https://developer.android.com/studio/test/monkey.html I read: -s Seed value for pseudo-random number generator. If you re-run the Monkey with the same seed value, it will generate the same…
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138
7
votes
2 answers

ImportError: No module named 'com.android'

I'm writing a simple test for Android app and it fails while trying to connect my device with this log: Traceback (most recent call last): File "D:/MonkeyRunnerTest/test/LaunchTest.py", line 3, in from com.android.monkeyrunner import…
1
2 3
31 32