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.
Note: To automate on a device connected via USB instead of Wi-Fi, have a look at 'Add a device connected via USB'.
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:
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)
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.
Open the 'Manage Device' dialog by pressing the Devices button from the Record Settings dialog. As we there is no Android device listed open the 'Add new Device' dialog by pressing the 'Add' button.
Choose 'Android' and follow the instructions to install the Ranorex service on your Android device.
Note: If you have more than one user account activated on your Android device, make sure that the Ranorex Service app is only installed and running on the owner's user account.
Note: If you do not have an internet connection on your device, download the Service app from the "Add New Device" dialog, connect your device via USB and copy the apk file to the SD card of the device. Open the copied apk file using a file explorer to install it (Make sure to allow installation of non-Market apps by enabling 'Settings -> Security -> Device Administration -> Unknown Sources').
Note: Another possible way to install the service apk is to download the Service app from the "Add New Device" dialog, open the command line and switch to the "Ranorex Android Tools" directory (<Ranorex Installation Folder>\bin\RxEnv\Android\tools). First of all, type "adb devices". If you installed the device's USB driver correctly, adb devices should list the connected device properly. Secondly, type "adb install <Download Folder>/<Name of Service App>.apk" to install the service app. After performing these steps, start the installed service app on your device.
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 from 'Manage Devices' dialog, 'Record Settings' dialog, or directly by starting the instrumentation wizard as described in the chapter Instrumentation Wizard - Android.
Note: 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.
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.
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
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.
After choosing an element, the 'Validate Element' dialog will pop up. In this dialog, the attributes which should be validated can be selected.
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
- type 'CallMethod' to the action name field of the invoke action
- add the method name to the first argument field
- 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.
After performing the test on the mobile device, the recording process can be stopped by pressing the 'Stop' button.
Run TestAfter recording and altering the action table, the test can be executed on the mobile device by pressing the 'Run' button.
- Ranorex Studio - The Layout
- Lesson 1: Getting Started
- Lesson 2: Ranorex Modules - Test Actions
- Lesson 3: Data-Driven Testing
- Lesson 4: Ranorex Test Suite
- Lesson 5: Ranorex Recorder
- Lesson 6: UI Mapping with Ranorex Repository
- Lesson 7: Code Modules
- Lesson 8: Reporting
- Lesson 9: Ranorex Spy
- Ranorex Settings
- Ranorex Remote
- User Code Library
- Selenium WebDriver integration
- Code Examples
- Data Connectors
- Instrumentation Wizard
- Technology Instrumentation
- RanoreXPath Weight Rule Library
- Ranorex UI Adapter
- Mobile Testing
- Android Testing
- iOS Testing
- Web Testing
- Source Control
- Ranorex Studio IDE
- Visual Studio Integration
- System Requirements
- 64-bit Platforms
- Remotely Working with Ranorex
- Silent Installation of Ranorex
- XCOPY Deployment
- How to instructions