Ranorex Help Center

How can we help you?

Android Testing

Learn how to automate your Android app testing for different devices and languages. The following sections will explain how to set up an environment for Android testing, how to generate and execute a test and what to do if any problems occur. The Android app KeePassDroid is taken as an example how to automate mobile applications using Ranorex.

Extended Information

After doing your first steps in mobile testing on Android devices please find the following chapters providing detailed information on more advanced topics and testing scenarios.


Before getting started with Android test automation, it's necessary to choose the connection type that suits your needs. The following overview helps you to find out which connection type will work best for you.

Record Replay Start/Stop App Install APK Deploy (unattended)

Automate System Apps



Even if automating via Wi-Fi it is recommended to have your system under test plugged into a power supply during test recording and execution.

Getting Started

This quick start guide will show you how easy it is to record your Android test and execute the test on different devices and Android languages.

Prepare your Android device

In order to ensure that the device connection is as stable as possible, it is recommended to enable the 'Developer Mode' on your Android device. This mode grants access to some advanced settings which are responsible for a stable connection. On Android 4.2 and higher, 'Developer Mode' is hidden by default. You can unhide it by navigating to 'Settings' -> 'About Phone' and tapping 'Build Number' for seven times. Now return to the previous screen and find 'Developer options' in the main menu:

Enter 'Developer options'

Enter 'Developer options'

Inside the 'Developer options' menu, please enable the following settings:

  • 'Stay awake' which prevents your device from going to Standby during test automation.

Note Although you might be automating via Wi-Fi, your devices should always be connected to a power supply to ensure both letting this setting work as well as ensuring to not run out of battery during your tests. Furthermore it disables any energy saving mechanisms for your Wi-Fi interface and makes the Wi-Fi connection more stable.

  • 'USB debugging' (only when automating via USB)
Enter 'Developer options'

Enter 'Developer options'

Start your first recording by pressing the record button in Ranorex Recorder.

Next to starting a desktop, web or instant recording it is also possible to start a mobile recording.

Choose technology to record

Record a mobile test

Add Device

Follow the instructions on how to add an Android endpoint.

Instrument and Deploy your Android App

After setting up the Android device, the app which should be automated has to be instrumented and deployed to the device.  The Instrumentation wizard for instrumenting and deploying an APK file can be started in the endpoint options, the 'Record Settings' dialog, or directly by starting the instrumentation wizard as described in the chapter Instrumentation Wizard - Android.

Note It's recommended to fresh instrument your app for every new Ranorex release. For further information have a look at the section Mobile Testing - Versioning.

Note The Instrumentation Wizard can be started from command line. For further details have a look at the section Instrumentation Wizard - Running Instrumentation Wizard from Command Line.

Note You can also instrument and deploy your APK in a recording or from code. For further details have a look the chapter 'Lesson 5: Ranorex Recorder - Additional Editing Options - Types of Actions' and the API documentation of the 'InstrumentAndDeployAndroidApp' method.

As mentioned before, the Android app KeePassDroid is taken as an example how to automate mobile applications using Ranorex. The APK file can be downloaded at https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/keepassdroid/KeePassDroid-1.99.10.apk.

Next to instrumenting and deploying your Android app, the Instrumentation Wizard allows you to update the Ranorex Service on your device as well as deploy the RXBrowser app, which enables web testing for Android.

After choosing a device to deploy and an APK file to instrument, the process will be started by pressing the 'Next' button.

Android Instrumentation Wizard

Android Instrumentation Wizard

Note Open the Advanced Instrumentation Settings dialog by clicking the Advanced button. Here you can change the APK signing as well as some instrumentation options. When enabling "Full image comparison", a more robust image comparison mechanism will be used. Enabling this option decreases the apps startup performance but might be useful when having problems with determining resource id's for images. When disabling "Tree simplification", UI-trees will remain unchanged. This means no post processing will take place, resulting in larger UI-trees. Disabling this option decreases the apps startup performance but might be useful when automating 3rd party controls.

After the instrumentation of the APK file, it will be automatically deployed to the selected device.
Successfully finished instrumenting and deploying APK

Successfully finished instrumenting and deploying APK

To finish the instrumentation and deployment process, the installation has to be confirmed on the mobile device.
Confirm installation of instrumented APK

Confirm installation of instrumented APK

Note Because the Ranorex automation lib uses non-public API and adds additional permissions to your APK, make sure you do not release automated APKs to an app store to avoid biased user experience.

Note If you have problems with instrumenting your APK using the instrumentation wizard or if you want to integrate the instrumentation into your build process, please have a look at the "Instrumentation with Source Code" section.

Record and Run an Android Test

After preparing the device and instrumenting the APK, the recording can be started by choosing the device on which the test should be executed and the app which should be tested.

Mobile Recording with chosen device and app

By pressing the 'Record' button, the instrumented app will be automatically started on the mobile device and a notification on the desktop will inform the user, that actions will be recorded directly on the mobile device.
Record notification

Record notification

During the recording process, the action table of the Ranorex Recorder will give a good overview over the performed steps, as the table is updated live.
Action table updates during recording process

Action table updates during recording process

Note: The recommended way to add a value to a text box is to tap on the text box before typing.

Note: It's recommended to wait a short period of time before operating on list elements after scrolling the list.

Note: It's recommended to touch the text of a list element and not the empty space next to the text when operating a list element.

During recording it's possible to add validations using the 'Validation' button. By pressing the button, a dialog will open where the element which should be validated can be chosen.

Select element to validate

Select element to validate

After choosing an element, the 'Validate Element' dialog will pop up. In this dialog, the attributes which should be validated can be selected.

Choose attribute to validate

Choose attribute to validate

Additionally to recording actions, it's also possible to add actions to the action table after the recording process. This can be done by dragging a repository item to the action table and choosing the action which should be performed from the menu.
Adding actions manually

Adding actions manually

After recording and adding actions manually, the action table might look something like the following.
Action table

Action table

Action #1 is a 'Run Mobile App' action which starts the instrumented APK file on the selected device.

Note You can add a launcher activity to your "Run Mobile App" action by simply adding the activity name to the "Startup Arguments" using the following syntax: <fullpackagename>/<fullpackagename.activityname>

Action # 2 is a Touch Event on a button. There are 5 different kinds of touch events recognized by Ranorex:

  • a normal 'Touch' which is equivalent to a mouse click on a desktop machine,
  • a 'Long Touch' which typically opens a context menu
  • and 'Touch Start', 'Touch Move' and 'Touch End' for simulating a drag gesture.

Note The duration for both, 'Touch' and 'Long Touch' can be defined int the properties pane. You can open this pane by clicking the context menu item 'Properties' on the 'Touch Event' action item.

Action # 4 is a 'Set Value' action, which is typically used for keyboard input.

Action # 6 is a 'Wait For Not Exists' action, which is useful when having for example an item indicating a loading process and the automation should go ahead when the item has disappeared.

Action # 7 is a 'Validate' action as described before.

Action # 8 is a 'Get Value' action, which can be used to write back an attribute value of a control to a variable for further processing.

Action # 9 is a 'Report' action, which is used to add information to the test report.

Action # 10 is a 'Invoke Action' which performs a scroll action on a list control to its index '0'. 'Invoke Actions' directly call the corresponding method of the selected control.

You can use the invoke action to call user defined methods or get and set user defined members.
To call such a user defined method

  1. type 'CallMethod' to the action name field of the invoke action
  2. add the method name to the first argument field
  3. add a value or a variable you want to pass to the method to the argument field or fields

To get or set a member use 'GetMember' or 'SetMember' instead of 'CallMethod' as action name.
For further details about invoke action have a look at Lesson 5: Ranorex Recorder - Additional Editing Options - Invoking User-Defined Actions.

User defined methods can also be invoked from code the same way. Here is a short example:

string text = (string) repo.App.Text.Element.InvokeAction("CallMethod", "myCustomGetTextMethod");
Dim text As String = DirectCast(repo.App.Text.Element.InvokeAction("CallMethod", "myCustomGetTextMethod"), String)

Action # 11 is a 'Mobile Key Press' action. 'Mobile Key Press' actions simulate the physical buttons 'Back' and 'Menu' of the mobile device.

Action # 12 is a 'Close Application' action. 'Close Application' actions stop the selected application on the mobile device.

Note Make sure to add a 'Close Application' action, when running your test on different devices, because if the app will not be closed on the devices, the app on the first identified device will be automated.

Stop Recording

After performing the test on the mobile device, the recording process can be stopped by pressing the 'Stop' button.

Stop recording

Stop recording

Run Test

After recording and altering the action table, the test can be executed on the mobile device by pressing the 'Run' button.