Record the script Configure runtime settings Enhance your script Run test Set up the environment

Enhance TruClient - Native Mobile scripts

Before you run your recorded script, you can increase its functionality by adding enhancements such as parameters and other mobile actions.

Multiple apps

TruClient allows you to record and replay business processes with multiple apps. In case of mobile, this can include systems apps, pre-installed apps on the device, and apps installed through the Digital Lab wizard (see the Digital Lab Help Center).

The Digital Lab tab in the Developer window, shows the installed apps.



The generated Using application step indicates the context in which the following steps are executed. For details, see Add actions.



When you expand the Using application step, the Step editor shows information about the app such as whether it was launched during startup and if it was one of the applications that Digital Lab uploaded.

This is useful during troubleshooting: If an object is not found, make sure the Using application preceding the step, is correct.

Back to top

Add actions

The simplest enhancement you can do, is to insert actions or events using the TruClient Steps box, while in the Actions tab:

  • Add generic device actions:

    • to add steps that are common for mobile users, such as press back, to simulate navigating back to the previous screen or pressing the menu button.
  • Add generic object actions:

    • to enhance your script with object actions that cannot be recorded

    • to change the way the action should be performed
    • to perform additional actions on test objects, see View or edit step objects.

  • Insert wait time

  • Add calls to functions

  • Add flow control
  • Evaluate JavaScript code

Object Exists end events

The end event of each step can be a native or web object in one of the following scenarios:

Native to Web. A native step waiting for a Web object to appear. TruClient allows you to use any of the object identification methods for Web objects. For details, see Object identification.

Web to Native. A Web step waiting for a native object to appear.

Web to Web. A Web step waiting for a Web object to appear.

Native to Native. A native step waiting for a native object to appear.

When using the Object Exists end event, TruClient determines the success of a step when the step action succeeds and the end event object is found.

In the last step of the script, by default, TruClient sets the end event to Action completed. You can manually change this value in the Step editor.



Native objects

When recording actions on native test objects and the next step is performed on another (or the same) native test object, TruClient automatically sets:

  • the end event to Object Exists
  • the current step's end event test object to be the next step's test object

If the end event object is a native object, you can require it to match a specific text property. Click the button by the End Event field to expand the Step editor and show the Property drop-down. For details, see View or edit step objects.

Non-native objects

For a non-native test object, TruClient sets the end event to Action Completed. You can, however, manually change it to Object Exists and specify an object.

Note: After recording, if you manually change the script, the object of the end event in the previous step remains as it was recorded. Therefore, if you manually manipulate the script, you must also adjust the end event object of the previous step.

Back to top

Manipulate the test object properties

As part of Digital Lab’s support for test object properties, you can modify the supported properties to indicate how an object is interpreted and recognized during the test run.

For native objects, the ArgsContext.getObject API lets you retrieve and manipulate object properties.

To implement this API, add the code to the JavaScript field in the Object section.

View properties

The following example shows how to retrieve an object's properties. This code should appear in the Object Identification section of a step which has an object.

var object = ArgsContext.getObject();

ArgsContext.TC.log(JSON.stringify(object), “Standard”);

Object;

You can then view the properties of the object in the in TruClient log.

You can use this for debugging, by temporarily editing the test object’s properties. This is useful when you need to:

  • manually improve the object identification
  • make a less strict object identification
  • identify objects based on the test object properties supported by Digital Lab

Delete a property

The following example shows how to delete an object's text property:

var object = ArgsContext.getObject();

delete object.text;

object;

Override a property

The following example shows how to override an object's text property:

var object = ArgsContext.getObject();

object.text = “a Better Text”;

object;

Generate random values

The following example shows how to generate random values for a non-uniform load test:

var object = ArgsContext.getObject();

var vals = ["LongPress", "TimeActivity", "DateActivity", "Spinners"];

object.text = random(vals);

object;

Back to top

Set up transactions

A transaction measures the time between two points in a business process. The measured time is known as the transaction response time. For a mobile test, the response time is the execution time on the device.

In TruClient - Native Mobile scripts, the start point is Step started and the end point is After Step ended. To obtain a step's response time, select Surround with Transaction from its right-click menu, and specify a transaction name.

To increase the accuracy of the transaction response time, use an Object Exists end event. This filters out the overhead caused by the communication between the TruClient browser and the Digital Lab server. For details about end events, see End events.

For TruClient - Native Mobile scripts, you can add suffixes to transaction names, such as the device ID or app name. This allows you to better identify the transaction in the results. For details, see Set up environment.

To set up a transaction, select a step and choose the transaction options from the right-click menu. For details, see Insert transactions.

You can view transaction data in LoadRunner Analysis. For details, see LoadRunner Analysis.

Back to top

Parameterize objects

It is often useful to use parameters for object identification. For example, if you recorded into your script the booking of a plane ticket, you can parameterize the name of the airport in your script.

To parameterize an object:

  1. Create a new parameter, for example: destAirPort.

  2. In the Object > Javascript section, include the following code:

    ArgsContext.TC.getParam("destAirPort");

    Note: ArgsContext enables you to refer to arguments defined outside the object identification section. For details, see Work with the ArgsContext object.

The object's structure must be identical in all the parameterized objects, but the text properties can be different.

Back to top

Parameterize Virtual User Generator values

TruClient integration with Digital Lab allows you to use parameters for the Digital Lab server credentials, device names, and app names instead of actual values.

To parameterize values:

  1. In VuGen, double-click the Parameters node in the Solution Explorer to open the Parameter List dialog box. For details, see Parameter List dialog box.
  2. Create new File type parameters for all the desired arguments and provide multiple values. For example you could create a parameter called DL_DeviceID, and enter multiple Device IDs.
  3. In the Parameter List dialog box, make sure to set the following usage options:

    Select next row: Unique

    Update value on: Once



  4. In VuGen, click Develop Script to open the TruClient browser. In the Digital Lab tab, go to the Arguments portion of the section to which you are applying the parameter.
  5. Click the drop-down arrow to the right of the argument field, and select the Parameter icon .
  6. Enter the parameter name that you created earlier.



  7. In VuGen, before replay, configure the Run Logic runtime settings to perform the number of iterations that corresponds to the number of values you provided for your parameter.

This configuration indicates to Digital Lab to use parameters instead of a constant value when running the test.

Benefits of using parameters

Parameters can assist you in your testing in the following ways:

  • Use a parameter in place of your app version to run regression tests on different versions of the app.

  • Use parameters in place of the server URL and credentials to test the performance of devices on different Digital Lab servers.
  • Use parameters to test your script on multiple devices. You can define parameters for any of the device capabilities or its unique identifier, obtainable from Digital Lab.

For more details about using parameters while developing a script, see Record Native Mobile scripts.

Back to top

See also: