September 4, 2013

Testing With Ranorex – A Mobile Testing Automation Tool

If you are looking at intuitive software testing automation solutions, then Ranorex is a product worth trying. The GUI test automation framework of Ranorex is just about what you need to carry out professional and functional test automation. The product comes with a 30-day trial period, allowing QA Engineers to test different mobile applications including Windows Apps and native Android/iOS apps.

Ranorex Test Automation Tool

Architecture of Ranorex

The extensive Ranorex Library modeled on the .NET framework is the bedrock of the widely popular Ranorex automation tool. C# and VB.NET user codes can be generated from recorded test cases. The test cases can be written without writing any line of code. It simulates the user actions by the record and replay tool into recording modules. It uses Xpath technology for the identification of objects.

The Ranorex API activates appropriate plug-ins depending on the platform. Ranorex Automation tool is supported on:

  • Android 2.2 (API Level 8) and higher.
  • IOS 5.1 and higher

Overview of Ranorex Components

Automated Testing Software

Popular Ranorex tools like Recorder, Repository and Spy are available under the fully integrated test development environment called Ranorex Studio. Here is an introduction to the layout of Ranorex Studio:

Ranorex Recorder
This tool lets you record test cases by recording and playing back a user’s actions as they navigate through the mobile application during the testing process.

In the recording mode, as the user browses the application, the recorder records the actions in the action table, which can also be changed manually later on. It offers validation mode during the recording sessions to validate text and images. Recorded actions and their associated UI elements are saved as individual items and therefore can be easily accessed and edited. Some of the actions that define the test cases are:

  • Open Browser
  • Run Mobile Application
  • Deploy Application
  • Get Value
  • Set Value
  • Mobile Key Press: Sub Actions are BACK, HOME, DEL, MENU, SEARCH, ENTER.
  • Validation
  • Invoke Action: Sub Actions are Ensure Visible, Focus.

Ranorex Spy
UI elements of an application are put through the scanner using a tool called Ranorex Spy. It is a query language which allows the tester to analyze/validate the application so as to identify and filter out various UI elements with ease. Mapping information of these GUI elements is provided by this tool to change the RanoreXPath.

Ranorex Repository

All the UI elements of the application being analyzed can be found under the Ranorex Repository. This tool is part of Ranorex Studio, the test development environment and also integrated with Ranorex Spy and Ranorex Recorder. Logical mapping of these UI elements can then be created using this repository which also helps in segregating test sequence actions and element identifications.

For this, Repository.rxrep file is created for each test project. It is a single point of change how the objects are identified in the project. From this, the user interface elements can be highlighted on the mobile device for more clarity. We can create different repositories for different test cases. The elements in the repository are mapped to the ‘Repository Element’ column in the Action table.


  • It supports cross platform testing: Test cases once written can be executed on different mobile devices like Android and iPhone.
  • It offers reliable user interface object recognition model which relies on Ranorex XPath technology. Ranorex uses Xpath technology for the identification of objects.
  • The Ranorex toolset allows you to automate your UI testing by recording your UI actions without the need to write any code. Although the test cases can be written through code, it also offers an automated test recorder, which records user actions on the mobile devices and allows you to play them afterward.
  • It offers a spy engine which exposes the details of each and every user interface element present on the screen of the application. Its excellent object recognition enables you to identify the UI elements of your application, regardless of whether it’s a Web or Windows based UI.
  • It records the test cases directly from the real mobile devices. When editing the recorded steps, there’s no need to write a single line of code.

iPhone Automation

Before installing the application on the device, the application under test has to be instrumented through a library (libRxAutomationUni_410.a) using XCode. Ranorex’s automation tool recognizes the application as soon as the instrumented application is launched on an iOS device. To make a connection to the device, the application has to be in the foreground. Automation of the Home key is not supported by the automation tool, as after the application is closed the connection to the device is also gone. Automated launching and deploying of iOS apps is only supported by the new version Ranorex 4.1, where USB support for iOS is also introduced.

Android Automation
The automation tool requires a Ranorex Services .apk to be installed on the device under test. The tool instruments the application while deploying on the device. QA Engineers can follow these steps to connect Android phones with Windows machines:

  1. Open the Devices tab in Ranorex Studio Software.
  2. Select ‘Add’ to add the device. Follow the steps till end.
  3. Open the Command Line and move to ADB.exe path. Execute these commands in series until you see the Android device name connected to the Windows machine. You can disconnect the device and reconnect while executing these commands:
  • adb kill-server
  • adb start-server
  • adb devices

Software Installation Requirements

  1. JRE 1.6 must be installed on the machine conducting the test.
  2. Ranorex installer is only available for Windows-based operating system machines.
  3. For Android, only the .apk of the application is required for the automation. Neither the source code nor the signature or the private key is required. For iPhone, the application has to be instrumented through a library (libRxAutomationUni_410.a) using XCode.
  4. On Android devices, to automate the native applications, the Ranorex Service .apk application has to be installed.
  5. On iPhone, to automate the web application, a browser app (RxBrowser) has to be installed. For more information:
  6. The Android application should not be obfuscated.

Observations while analyzing the software

  1. Cross Device Testing or Supports Multiple Device Testing: The most useful feature of the Ranorex software is that test cases, once created, can be executed on multiple devices, like iPhone and Android. This requires only one change in the test cases: changing the name of the connected device.
  2. Keyword-based creation of scripts.
  3. The automation tool can install/deploy third party applications on the device under test. It deploys the .apk file after instrumenting the application. In the script, only the location of the .apk file has to be mentioned. After installation, the application is available for testing either manually or automated.
  4. The automation script can launch any third party application. If the application is already installed on the device, the application has to be removed and re-installed through the Ranorex Instrumentation wizard. In other words, the application has to be instrumented and it should be known to the Ranorex Services application installed in the device.
  5. While the automation script runs, the mobile device has to be in an unlocked state. In the locked state, the software is not able to find or scan user interface components.
  6. The Ranorex script can be executed from anywhere in between the commands of a particular test case. It is not required that the script will be executed from the first action/command. Actions in a particular test case can also be commented.
  7. Support waiting mechanism. The script can wait for the appearance of a particular user interface element on the screen and based on this action consecutive actions can be performed further. This is so called SearchTimeOut.
  8. Supports Text validation of any textview present on the screen. For this validation, a variable is specified and attached to the test case.
  9. Stores and retrieves user interface text into a variable: The tool is able to read text strings from any UI component and is able to store them in variables. The test cases can later use these variables in a particular scope. I have created a sample script which extracts the value from the Edittext and Button and sets in another Editext.
  10. Supports image-based validation: Images in the application can be compared with an expected image as whole or subset of an image. The image under test can be the screenshot of the application or it can be uploaded in the software.
  11. Accessibility of the Reports outside the Ranorex environment: Reports are accessible outside the Ranorex software environment. These reports can be opened in any browser. Some browsers restrict the webpages to execute scripts or Active X controls and so the reports can also be blocked. We have to allow these scripts to run on browsers. Internet Explorer is the best browser to do so. For this, we have to change the file extension from .rxlog to .html. This has to be done for data files also.
  12. Scroll and Search Feature on Scrollview: The software can scroll on the screen and perform any action. There can be a scenario where the user has to scroll and then click on a button or validate a text. In the attached test cases, I have validated a text and an image which are not visible on the screen but they are present on the hierarchy tree. The script validates the text and compares the image also.
  13. Scrolls and Selects Item on Listview : The software can scroll a listview and based on the index, it can select row of the listview. This feature is tested to be incompatible on the applications build targeted on API Level 10. When the same application was built on API Level 14 and above, the Ranorex software was able to automate the Listview and work on it.
  14. Supports Data Driven Approach:  The software can manage various data sources. For help, follow here. Among the data sources, the options available are:
    1. Microsoft Excel Sheet with support for workbooks.
    2. Simple Data Table
    3. SQL Connector
    4. CSV File.
  15. Error Handling Mechanism: If the software encounters some errors while executing the test cases, the execution of the test cases are aborted by default. To prevent this, especially when multiple test cases are executed, the teardown option makes it possible to execute some test cases to run finally.
  16. Execution of test cases from Command Line: The test cases and the recording modules can be executed from outside the Ranorex Studio software. These can be executed from the command prompt.
  17. Continue Script execution on Failure of a test case: There is the error behavior that can be set for each test case separately. Please read more about that topic here.
  18. Conditional testing:  If/Else conditions can be done in user-code in the background. Simply convert one or more actions in your actions table to user-code, and then implement the if/else-condition:

Conditional testing


19. Mobile Key press commands do exist for:

  1. Back Key
  2. Home Key
  3. Menu Key
  4. Enter Key
  5. Delete Key
  6. Search Key
    On iPhone Apps, only the Enter Key works through the automation tool.

20. The software specifically has no commands that simulates:

  1. Accessing the media files from the internal/external/external SD card of the device.
  2. Power On/Off key
  3. Volume Up/Down
  4. Camera Button

21. The software works efficiently on the following user interface controls:

  1. Button Clicks
  2. Listview item selection
  3. Checkbox selection
  4. Radio Button selection
  5. Textview string validation
  6. Editext/Textfield string validation
  7. Image based validation

22. Reporting: After the test cases are executed, the software generates reports for each test case and for each test suite, if test suites are executed. The following information can be gathered from the reports:

  • A general overview of how many of the test cases have been executed successfully, have failed or have been blocked.
  • For each run of a test suite/single test case/recording, a log file (*.rxlog) is created in a project’s Report folder.
  • System information like execution time, machine name, operating system, screen dimensions, language, duration, total errors, total warnings.
  • Screenshots and snapshots can be included in the reports. For this, actions have to be added in the recorder script.
  • UI elements mentioned in the report can be analyzed with the Ranorex Spy directly from here.
  • The reports can be customized. Some changes can be changed like style of the reports, structure of the report etc depending on the requirement of the client.

23. Gestures like Swing, Scroll, Drag/Drop : These gestures can be automated. These are defined by ‘Touch Action’ ‘Touch Start‘, ‘Touch Move‘, ‘Touch End‘ action.

24. UI Automation: The automation tool can test the placement and the alignment of user interface elements. There are several ways to do this. It can be done either image-based (so on the base of screenshots), or on the base of the object’s position using the “screenRectangle” property of a repository element:

UI Automation

Limitations Known for Mobile Devices

  1. The Track Button functionality on Ranorex Spy does not work for testing on mobile devices.
  2. Android Web based and hybrid applications are not supported by the automation tool. The Ranorex repository is unable to identify user interface elements on the mobile browsers.
  1. On iPhone Devices, the automation tool can test native apps and web based apps separately. iPhone Web applications are tested on instrumented RXBrowser app, provided by Ranorex. Hybrid applications for iOS work out of the box. If you open Ranorex Spy, you should see the native controls of the app as well as the DOM that is returned by the web view. So you will no longer need RxBrowser as soon as you have your separate hybrid app, which contains both native and web controls (the RxBrowser is basically just a hybrid app, so a native container containing the web view).
  2. To automate the iPhone applications, the application has to be instrumented by using the XCode through a library (libRxAutomationUni_410.a) before installing in the device. Also, the instrumented application has to be manually installed on the device. After the launch of the application, the automation tool detects the device under test. Prior to this, the device remains in a disconnected state.
  3. Automation of the Home Key Press does not work for Android and iPhone Devices.
  4. Installation. deployment and launching of iPhone applications cannot be automated. In iPhone, the application has be installed and launched manually.
  5. On both OS apps, interrupts like incoming or an outgoing call or sms/email cannot be injected in to the script while it is executing.