MobileDevice Object

Supported in UFT versions 14.03 and higher.

Description

Represents the devices available in the Mobile tab of the Record and Run Settings dialog box.

You must have a UFT connection to Mobile Center before using this test object.

Record and Run Settings

You must have the following Record and Run Settings defined before using this test object:

Then, use the MobileDevice object to switch between working with a specific device vs reserving a device by capabilities.

For example:

If the Record and Run Settings are currently defined to ...

... Set your properties as follows:

Use a specific device (by device ID) Use the ManufacturerAndModel or the OSVersionCriteria properties to switch to reserving a device by capability.
Reserve a device by capability

Set the ID property to switch to using a specific device by device ID.

In such cases, do not use the ManufacturerAndModel and OSVersionCriteria properties in your script.

After switching, any properties irrelevant to the current settings are set to empty. The OS property value is always kept.

Properties

ID Property

Defines the device ID. Required for selecting a specific device.

ManufacturerAndModel Property

Defines the device's manufacturer and model. Optional for selecting a device by capability.

OS Property

Defines the device's operating system. Required for selecting a specific device, or for selecting a device by capability.

OSVersionCriteria Property

Defines the device's operating system version. Optional for selecting a device by capability.

TargetLab Property

Read-only. Defines the device lab used in the record or run session. Optional for selecting a device by capability.

Example

Define a device to use in your test

'Create a QTP object

Set QTP = CreateObject("QuickTest.Application")

QTP.Launch

QTP.Visible = True

 

'Open a UFT test

QTP.Open "C:\Users\Administrator\Desktop\scripts\Android\UFT_Replay_Android_NativeBrowser", TRUE 'Set the UFT test path

 

Set qtMobileLauncher = QTP.Test.Settings.Launchers("Mobile")

qtMobileLauncher.Lab = "SRF"

qtMobileLauncher.Device.ID = "N2F4C15923006550"

qtMobileLauncher.Device.OS = "Android"

qtMobileLauncher.EnableWebSettingForMobile


'Set test options

qtMobileLauncher.InstallApps = true

qtMobileLauncher.RestartApps = true

qtMobileLauncher.UninstallApps = false

qtMobileLauncher.TrackCPUMetric = true

qtMobileLauncher.TrackMemoryMetric = true

qtMobileLauncher.TrackFreeMemoryMetric = true

qtMobileLauncher.TrackLogs = true

 

'Set result location

Set qtpResultsOpt = CreateObject("QuickTest.RunResultsOptions")

qtpResultsOpt.ResultsLocation = "C:\Users\Administrator\Desktop\scripts\Android\UFT_Replay_Android_NativeBrowser" + "\Results" 'Set the results location

 

'Run the test

QTP.Test.Run qtpResultsOpt

 

'Close UFT

QTP.Test.Close

QTP.Quit