MobileDevice Object

Supported in UFT One 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 One connection to Mobile Center / UFT Mobile / Digital Lab before using this test object.

Record and Run Settings

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

  • On the Mobile tab, select Use Mobile Center, Use UFT Mobile, or Use mobile device depending on your UFT One version.
  • On the Web tab, select Use settings on the Mobile tab.

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)

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.

Reserve a device by capabilityUse the ManufacturerAndModel or the OSVersionCriteria properties to switch to reserving a device by capability.

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

Properties

ID

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

ManufacturerAndModel

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

OS

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

OSVersionCriteria

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

TargetLab

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

Copy code
'Create a QTP object
Set QTP = CreateObject("QuickTest.Application")
QTP.Launch
QTP.Visible = True
 
'Open a UFT One test
QTP.Open "C:\Users\Administrator\Desktop\scripts\Android\UFT_Replay_Android_NativeBrowser", TRUE 
'Set the UFT One test path
Set qtMobileLauncher = QTP.Test.Settings.Launchers("Mobile")
qtMobileLauncher.Lab = "DigitalLab"  'UFT One 2023 or earlier: "MobileCenter"
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" 

'Run the test
QTP.Test.Run qtpResultsOpt
 
'Close UFT One
QTP.Test.Close
QTP.Quit