The MonkeyRunner Transform controls an Android device attached to your PC using the ADB.
The Monkeyrunner Transform has been tested with the following:
• Bundle for Windows 64-bit: adt-bundle-windows-x86_64-20140321.zip – Download
•Python 3.4.1 or newer – Download
•Java - Download
To run the Monkeyrunner demo, use the following steps:
1.Download Android SDK tools for Windows from https://developer.android.com/studio/#downloads
2.Use the downloaded installer to install the tools.
3.Select C:\Program Files\Android\Android Studio for the Destination Folder:
4.Open a Command Prompt window and enter adb as shown below:
If the following error is displayed, set the PATH environment variable:
'adb' is not recognized as an internal or external command, operable program or batch file.
If SDK is installed in the C:\Android\android-sdk folder, you need to update the path to include: C:\Android\android-sdk\platform-tools;C:\Android\android-sdk\tools;
1.From the Windows Start button, select Control Panel->System->Advanced system settings.
2.Click the Environment Variables button.
3.Select the Path variable and click Edit:
4.Add the following to the Path variable:
5.Click OK twice to save and close the dialog.
6.Test that adb is working as explained in step 2.
1.Download Python 3.4.1 (or newer version).
2.Install python-3.4.1.msi (or newer version) on your machine.
3.Enter Python to confirm that Python is working as shown below:
If an error message is displayed, update the PATH variable for python folder.
You can connect to the Android device using a USB cable or Bluetooth:
1.Connect the Android device to your PC using a USB cable.
2.Enable the USB debug mode on the Android device.
Enable Bluetooth on the Android device.
2.Create a new project or open the MonkeyRunner sample project.
4.If necessary, create the MonkeyRunner Transform. If you are using multiple devices, create a Transform for each device.
Click to expand.
5.Do the following for each MonkeyRunner Transform:
a.Be sure the Monkey Runner Batch Path is set. If it is not, review the installation steps.
b.Set the Device Connection Timeout to the value for your device. (The Galaxy Tab takes as many as 20,000 ms to connect.)
c.Set the Selected Device property to the Device Id for the corresponding device.
To determine the Device Id for all connected devices, enter the adb devices command into a command prompt:
The top 4 inports on the MonkeyRunner Transform are event ports. MKREnable is a Boolean numeric port. Snapshot is a message port. ScriptComplete is an event port. Busy is a discrete numeric port.
In a TestCase, double-click on the plot line of the mPress Signal to create a transition. Each transition simulates a key press of the specified key and type.
The listed keys are device dependent. Some devices do not have all keys. If the key does not exist on the device, it may not work.
In a TestCase, double-click on the plot line of the mTouch Signal to create a transition. Each transition simulates touching the Android device's screen at the specified coordinates.
The Long Press Touch Type includes an additional parameter to specify the length of the touch. The default value is 0.5 seconds.
To get the screen co-ordinates, run wGetAndroidSnapshot.exe.
Select the ADB path. Select Device as the source type. Press the Get snapshot button to show the device display in the preview window. Then press MRH button at the right lower corner and the Monkey Runner helper window opens as shown below.
Touch the screen to generate the co-ordinates.
In a TestCase, double-click on the plot line of the Script Execute Signal to create a transition. Each transition on the Signal executes the selected Python or Shell script.
Create a script by clicking the Device Recorder verb in Properties box as shown below:
Press the Start button and select the file path for the script. Operate the device and press the Stop button. All operations are saved as a script.
To execute the script previously recorded, click the Execute button.
To execute the script from a TestCase, create a transition as described above.
Set to 1 to enable the Transform. Set to 0 to disable. The default value is 0 (disabled).
When using multiple devices, rename your Signals so that the Signals for each device have unique names. For example, if you have
a Samsung Galaxy and an HTC phone, add prefixes such as SS and HTC to the Signal names to make it clear that SS_mTouch connects
to the Samsung Galaxy, and HTC_mTouch connects to the HTC phone.
To rename the ports, use Signal Info in the Port Properties box. You cannot use Edit Ports or the Transform properties.
It is best to rename the ports before exporting. If the ports are already exported, see Renaming Ports.
Port Properties for the mTouch Port
This TestCase shows multiple Transforms and devices being tested concurrently.
The following TestCases are included in the Monkeyrunner sample project.
The VolumeDemo TestCase adjusts the volume on the Galaxy tablet up and down.
The TouchDemo TestCase saves the contacts on the Galaxy device.
The ScriptExecute TestCase runs the sample.sh script file.
Issue: Batch Path and Jar Path are not displayed in the Transform's Properties
This is usually indicates that Android Studio was incorrectly installed in a local user directory.
There are two ways to fix this:
•Set an environment variable named MXVANDROIDSDKROOT and set its value to the installation directory C:\Users\demouser\AppData\Local\Android\Sdk\
•Uninstall Android Studio and then reinstall it for all users. (should be an option during the installation process).
Then restart the PC and open the project.