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.
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: http://www.ranorex.com/support/user-guide-20/ranorex-studio-the-layout.html
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.
- Touch: Sub Actions are TOUCH, DOUBLE TAP, LONG TOUCH, TOUCH START, TOUCH MOVE, TOUCH END.
- Invoke Action: Sub Actions are Ensure Visible, Focus.
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.
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.
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.
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:
- Open the Devices tab in Ranorex Studio Software.
- Select 'Add' to add the device. Follow the steps till end.
- 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
- JRE 1.6 must be installed on the machine conducting the test.
- Ranorex installer is only available for Windows-based operating system machines.
- 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.
- On Android devices, to automate the native applications, the Ranorex Service .apk application has to be installed.
- On iPhone, to automate the web application, a browser app (RxBrowser) has to be installed. For more information: http://www.ranorex.com/support/user-guide-20/ios-testing.html
- The Android application should not be obfuscated.
Observations while analyzing the software
- 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.
- Keyword-based creation of scripts.
- 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.
- 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.
- 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.
- 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.
- 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.
- Supports Text validation of any textview present on the screen. For this validation, a variable is specified and attached to the test case.
- 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.
- 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.
- 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.
- 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.
- 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.
- Supports Data Driven Approach: The software can manage various data sources. For help, follow here. Among the data sources, the options available are:
- Microsoft Excel Sheet with support for workbooks.
- Simple Data Table
- SQL Connector
- CSV File.
- 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.
- 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.
- 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.
- 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:
19. Mobile Key press commands do exist for:
- Back Key
- Home Key
- Menu Key
- Enter Key
- Delete Key
- Search Key
On iPhone Apps , only the Enter Key works through the automation tool.
20. The software specifically has no commands that simulates:
- Accessing the media files from the internal/external/external SD card of the device.
- Power On/Off key
- Volume Up/Down
- Camera Button
21. The software works efficiently on the following user interface controls:
- Button Clicks
- Listview item selection
- Checkbox selection
- Radio Button selection
- Textview string validation
- Editext/Textfield string validation
- 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:
Limitations Known for Mobile Devices
- The Track Button functionality on Ranorex Spy does not work for testing on mobile devices.
- 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.
- 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).
- 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.
- Automation of the Home Key Press does not work for Android and iPhone Devices.
- Installation. deployment and launching of iPhone applications cannot be automated. In iPhone, the application has be installed and launched manually.
- 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.