The TruClient – Native Mobile protocol provides a novel way to record and replay native mobile applications on both Android and iOS devices. The protocol enables the developers or DevOps engineers to record user interactions on the mobile applications and create TruClient scripts.
After recording the business process you want to test, you usually want to enhance the script to represent multiple Virtual Users (Vusers) or supply different inputs during the load test’s execution.
Using parameters and changing the Object Identification method
This is done in TruClient by supplying parameters to the step arguments using the TCA.getParam function. For example, when you want to parameterize the searched item in a search step, you can parameterize the Value parameter of a Type step, just as you always did in TruClient:
In the example above, you can see that selecting an airport creates a step for the Tap action, and the object is identified according to its string visualization (among other internal properties).
This approach works for objects that follow the same layout structure, like lists and labels, and more. It doesn’t work for objects that are in completely different structures on the screen, but in any case, you don’t usually need to parameterize these kinds of objects.
Notice that in some Roles and actions the object parameterization is bundled in the arguments. For example, selecting a radio button inside a radio group can be parameterized using the arguments:
In rare cases, you might find yourself failing to record a certain object on the screen. Tapping on the screen will not generate a step. This might be caused by a customized control that UFT Mobile fails to recognize. As a workaround, you can use Analog mode. Switching to Analog mode generates steps of the type Touch on Device with arguments of X and Y coordinates:
Guess what this step does? It simulates a tap on the given point. This way you can overcome problems in recording. Switch to Analog mode for the specific control and then switch back.
The drawback in Analog Mode is the resolution differences between the devices. In regular mode, a step recorded on a mobile phone also works in a tablet, while in Analog mode it might not work. You can add an If step to run a different Touch on Device step for each device to overcome it.
As part of the business process you are recording, you may need operations from the device itself. These may include pressing the ‘Back’ button to go to the previous screen or simulating a phone call that arrives and the application should handle. You can do this by using a Generic Device Action step (available from the Functions tab in the Steps box).
The available actions on the device vary according to the currently selected device operating system – Android or iOS. For details, see TruClient Steps box for native mobile.
Understanding the Scroll action
TruClient – Native Mobile usually adds a Scroll action on an object that needs to be scrolled in order to perform some operations on it. For example, tap on it. In Android devices, every object that has a role of Scroller will contain a scroll action as part of the step’s available actions. In iOS devices, certain roles will have a Scroll action (like CollectionView, Table, etc.). This means that you don’t normally need to add a scroll action as a generic device action. But what happens if you fail to record a certain action on the application? How will you reach the object in order to perform a ‘Touch on Device’ step? Use the Scroll on Device step to simulate the scroll operation on an abstract object. Let’s take a look at the arguments:
The Direction can be either forward or backward. The Object index represents the object that you want to scroll on. TruClient looks for all the scrollable objects in the screen from the top left to the bottom right and performs a scroll on the object with the specified index. This lets you perform scrolls to bring your object to the screen.
In this blog, I covered some more advanced features in TruClient – Native Mobile that enable you to enhance the script. In the next post, I’ll talk about the extended log and how to run one script on multiple devices. Hope you are enjoying reading this series!