Mobile Center features in LeanFT tests

This topic describes how to use various Mobile Center features in LeanFT tests.

Fingerprint and facial recognition authentication

When running tests on mobile devices, use the mobile application test object's simulateAuth* methods and properties to simulate fingerprint and facial recognition authentication. For details, see the .NET, Java, and JavaScript SDK references.

Back to top

Simulate scanning a barcode or QR code

In your mobile LeanFT tests, you can include steps that simulate scanning a barcode or QR code using an image file. Use the mobile application test object's simulateBarcodeScan method in the LeanFT SDKs. For details, see the .NET, Java, and JavaScript SDK references.

Back to top

Service Virtualization integration (early access)

Note: Supported from LeanFT 14.51, for LeanFT Java and .NET tests running on Windows machines.

If your Mobile Center is set up to integrate with Service Virtualization (SV), your LeanFT tests can include SV actions in your tests. These steps use scenarios that were created in advance from SV learning sessions.

To use this integration you must perform the following steps:

  1. Set up Mobile Center integration with SV, and prepare the service and scenario files that you want to use.

    For details, see Service Virtualization integration in the Mobile Center Help Center.

  2. Set up LeanFT integration with Mobile Center.

    For details, see Connect LeanFT and Mobile Center and Create mobile tests.

  3. In your mobile test perform the following steps:

    Step Java SDK .NET SDK

    Lock a device and enable SV for this session.

    When locking the device, set the DeviceSessionOptions class's EnableServiceVirtualization property to true.

    setEnableServiceVirtualization

    EnableServiceVirtualization

    Upload the service to the device.

    Sends Mobile Center the service definition. Mobile Center then communicates with SV to upload the service.

    svUploadService SvUploadService

    Upload the scenario to the device.

    Send Mobile Center the path to the folder that contains the scenario definition files. Mobile Center then communicates with SV to upload the scenario and make it available in this session.

    svUploadScenario SvUploadScenario

    Start the scenario.

    Instruct Mobile Center to have SV start the scenario so that you can use it to test your application.

    Then, perform steps on your application that require this scenario for testing.

    svStartScenario SvStartScenario

    Stop the scenario.

    When you no longer need the scenario to simulate the service's behavior for your test, stop the scenario.

    svStopScenario SvStopScenario

    You can also see .NET and Java code samples for using service virtualization.

Back to top

Check device vitals

LeanFT's mobile SDK includes an API for checking a device's CPU and memory usage. The information retrieved is an accumulation of the vitals from the moment the device was locked until it has been released.

Use this capability using the lock device API. For details, see .NET, Java, and JavaScript SDKs.

This enables collecting the vitals for the locked device by calling the getVitals method.

The returned value of this method, is a string in the following format:

<requestedVitalName1> <value> <timestamp>

<requestedVitalName2> <value> <timestamp>

<requestedVitalName3> <value> <timestamp>

<requestedVitalName1> <value> <timestamp>

<requestedVitalName2> <value> <timestamp>

<requestedVitalName3> <value> <timestamp>

The following is an example in C#:

{
	// lock a device and ask to collect CPU and FreeMemory
       var deviceDesc = new DeviceDescription { Name = "MyDevice" };
	var deviceSessionOpts = new DeviceSessionOptions
	{
		CollectVitals = new DeviceVitalsCollectOptions
		{
			CollectCPU = true,
			CollectFreeMemory = true,
			CollectMemory = false
		}
	};
	var device = HP.LFT.SDK.Mobile.MobileLab.LockDevice(deviceDesc, deviceSessionOpts);

	// ... do something
       // get the collected vitals
       var vitals = device.GetVitals();

	// process vitals
       var vitalLines = vitals.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
	foreach (var vitalLine in vitalLines)
	{
		var vitalLineParts = vitalLine. Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
		Console.WriteLine(String.Format("at {0}: {1} = {2}", vitalLineParts[2], vitalLineParts[0], vitalLineParts[1]));
	}
}			

View the accumulated data for the device vitals in the LeanFT run report:

  • View a graphical representation of the data collected over time in the System Monitor tab.

  • Hover over an area in the graph to see the device vitals relevant to that point in time.

Back to top

See also: