Object Model Reference for GUI Testing > Mobile > Back Method

Device Object

Description

A mobile device.

Operations

The sections below list the built-in methods and properties that you can use as operations for the Device object.

Note: You can also view a list and descriptions of the Device description properties, for use in object repository descriptions, programmatic descriptions, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.

Methods

Method Back Presses the device's Back button. (Android Only)
Common Method Check Checks whether the actual value of an item matches the expected value.
Common Method CheckProperty Checks whether the specified object property achieves the specified value within the specified timeout.
Common Method ChildObjects Returns the collection of child objects contained within the object.
Method ClickOnText Clicks the specified location on the device, relative to the recognized text string.
Method CloseViewer

Closes the Mobile Center remote access window.

You can use this method together with the OpenViewer method to open and close the remote access window during a run session.

For example, if you run your tests silently (configured in Tools > Options > GUI Testing > Mobile), you can open the remote access window to do the following:

- Run steps on Insight objects

- Perform bitmap checkpoints

- Record and run analog steps via UFT (not relevant for analog steps via the Mobile Center Options panel).

Then you can close the window after the steps run to continue running the test silently.

For more details, see the Mobile Center Help.

Common Method GetROProperty Returns the current value of the specified description properties from the object in the application.
Common Method GetTOProperties Returns the collection of properties and values used to identify the object.
Common Method GetTOProperty Returns the value of the specified description properties from the test object description.
Method GPSRelocate Simulates a change in the device's GPS location. (Android Only)
Method Home Presses the device's Home button. (Android Only)
Method IncomingCall Simulates an incoming call and optionally sends the app to the background for the specified number of seconds.
Method IncomingSMS Simulates an incoming SMS and optionally sends the app to the background for the specified number of seconds.
Method Menu Presses the device's Menu button. (Android Only)
MediaFileExists Checks if the file for sensor simulation exists on the Mobile Center server.
Method OpenViewer

Opens the Mobile Center remote access window. You can use this method together with the CloseViewer method to open and close the remote access window during a run session. For example, if you run your tests silently (configured in Tools > Options > GUI Testing > Mobile), you can open the remote access window to run steps on Insight objects, perform bitmap checkpoints, or record and run analog steps via UFT (not relevant for analog steps via the Mobile Center Options panel). Then you can close the window after the steps run to continue running the test silently.

For more details, see the Mobile Center Help.

Common Method Output Retrieves the current value of an item and stores it in a specified location.
Method RecentApps Opens the list of recent applications. (Android Only)
Common Method RefreshObject Instructs UFT to re-identify the object in the application the next time a step refers to this object.
Method SetOrientation Sets the device orientation.
Common Method SetTOProperty Sets the value of the specified description properties in the test object description.
Method Shake Perform a Shake gesture on the device.
Method StartNV Starts the Network Virtualization service using the specified network profile.
Method StopNV Stops the Network Virtualization service.
Method Swipe Swipes the device in the specified direction.
Common Method ToString Returns a string that represents the current test object.
Method Touch Touches the device at the specified coordinates. (Android Only)
UploadMedia Uploads a file for sensor simulation to the Mobile Center server.
Common Method WaitProperty Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.

Properties

Common Property Exist Checks whether the device currently exists in the Mobile server.

 

Back to top

Back Method

Description

Presses the device's Back button. (Android Only)

Syntax

object.Back

Return Type

None


 

Back to top

ClickOnText Method

Description

Clicks the specified location on the device, relative to the recognized text string.

Syntax

object.ClickOnText Text, [index], [offsetX], [offsetY]

Arguments

Parameter Description
Text Required. A String value.
The text string recognized by the OCR mechanism.
index Optional. An integer value.

The instance number of the recognized text string. The default value is the first instance of the string.


Default value = 0
offsetX Optional. A Single Value.

The offset on the x-axis from the recognized text string, in bitmap percentage values.

This percentage is used to determine the x-coordinate of the clickpoint.

The default value is at the center of the recognized string.


Default value = 0
offsetY Optional. A Single Value.

The offset on the y-axis from the recognized text string, in bitmap percentage values.

This percentage is used to determine the y-coordinate of the clickpoint.

The default value is at the center of the recognized string.


Default value = 0

Return Type

None

IMPORTANT

This method depends on UFT's OCR mechanism. For details, see the section on Guidelines for Text Recognition in the UFT Help Center.

Example


 

Back to top

CloseViewer Method

Description

Closes the Mobile Center remote access window.

You can use this method together with the OpenViewer method to open and close the remote access window during a run session.

For example, if you run your tests silently (configured in Tools > Options > GUI Testing > Mobile), you can open the remote access window to do the following:

- Run steps on Insight objects

- Perform bitmap checkpoints

- Record and run analog steps via UFT (not relevant for analog steps via the Mobile Center Options panel).

Then you can close the window after the steps run to continue running the test silently.

For more details, see the Mobile Center Help.

Syntax

object.CloseViewer

Return Type

None


Back to top

EnterKeys Method

Description

Uses the device’s keyboard to enter information.

Syntax

object.EnterKeys InputKeyType, value

Arguments

Parameter Description
InputKeyType

Required. An enumeration.
The type of value sent to Mobile Center for the device input.

Possible values:

  • typeValue (0)
  • typeKey (1)
value Required. A string.
The string to enter in the device..

 

Back to top

GPSRelocate Method

Description

Simulates a change in the device's GPS location. (Android Only)

Syntax

object.GPSRelocate Latitude, Longitude

Arguments

Parameter Description
Latitude Required. A double floating value.
The latitude coordinate of the new location.
Longitude Required. A double floating value.
The longitude coordinate of the new location.

Return Type

None

Example


 

Back to top

Home Method

Description

Presses the device's Home button. (Android Only)

Syntax

object.Home

Return Type

None


 

Back to top

IncomingCall Method

Description

Simulates an incoming call and optionally sends the app to the background for the specified number of seconds.

Syntax

object.IncomingCall From, [TimeInBackground], [RespondToEvent]

Arguments

Parameter Description
From Required. A String value.
The caller ID of the incoming call.
TimeInBackground Optional. An integer value.

The amount of time (in seconds) that the application remains in the background when an incoming call step is run.

Relevant only if the RespondToEvent argument is set to True.


Default value = 10
RespondToEvent Optional. A Boolean value.
Indicates whether the application should be sent to the background for the number of seconds specified in the TimeInBackground argument.
Default value = False

Return Type

None

Example


 

Back to top

IncomingSMS Method

Description

Simulates an incoming SMS and optionally sends the app to the background for the specified number of seconds.

Syntax

object.IncomingSMS From, Text, [TimeInBackground], [RespondToEvent]

Arguments

Parameter Description
From Required. A String value.
The caller ID of the incoming SMS message.
Text Required. A String value.
The text of the incoming SMS message.
TimeInBackground Optional. An integer value.

The amount of time (in seconds) that the application remains in the background when an incoming SMS step is run.

Relevant only if the RespondToEvent argument is set to True.


Default value = 10
RespondToEvent Optional. A Boolean value.
Indicates whether the application should be sent to the background for the number of seconds specified in the TimeInBackground argument.
Default value = False

Return Type

None

Example


 

Back to top

Menu Method

Description

Presses the device's Menu button. (Android Only)

Syntax

object.Menu

Return Type

None


Back to top

MediaFileExists Method

Description

Checks if the file for sensor simulation exists on the Mobile Center server.

Syntax

object.MediaFileExists ReferenceName, [FilePath]

Arguments

ReferenceName

Required. A string value.

The reference name of the uploaded file returned when running a UploadMedia step.

FilePath

Optional. A string value.

The path to one image or video file. This value can be a URL or the file system path of the file.

Return Type

None


 

Back to top

OpenViewer Method

Description

Opens the Mobile Center remote access window. You can use this method together with the CloseViewer method to open and close the remote access window during a run session. For example, if you run your tests silently (configured in Tools > Options > GUI Testing > Mobile), you can open the remote access window to run steps on Insight objects, perform bitmap checkpoints, or record and run analog steps via UFT (not relevant for analog steps via the Mobile Center Options panel). Then you can close the window after the steps run to continue running the test silently.

For more details, see the Mobile Center Help.

Syntax

object.OpenViewer

Return Type

None

IMPORTANT

An app must be open on the device before running an OpenViewer step. You can do this by specifying the app in the Record and Run Settings or by adding a Device.App.Launch step prior to the Device.OpenViewer step.


 

Back to top

RecentApps Method

Description

Opens the list of recent applications. (Android Only)

Syntax

object.RecentApps

Return Type

None


 

Back to top

SetOrientation Method

Description

Sets the device orientation.

Syntax

object.SetOrientation Orientation

Arguments

Parameter Description
Orientation Required. A String value.

The orientation to set on the device.

Possible values:

  • LandscapeRight
  • Portrait

Return Type

None

Example


 

Back to top

Shake Method

Description

Perform a Shake gesture on the device.

Syntax

object.Shake

Return Type

None


 

Back to top

StartNV Method

Description

Starts the Network Virtualization service using the specified network profile.

Syntax

object.StartNV Profile

Arguments

Parameter Description
Profile Required. A String value.
The name of the profile containing the conditions that you want to apply to the virtualized network. The profile must be set up on the Network Virtualization product.

Return Type

None


 

Back to top

StopNV Method

Description

Stops the Network Virtualization service.

Syntax

object.StopNV

Return Type

None

IMPORTANT

This method also adds a line to the run results, indicating where the network virtualization results file is located on the Network Virtualization server. This file contains traffic and performance information and analysis.


 

Back to top

Swipe Method

Description

Swipes the device in the specified direction.

Syntax

object.Swipe Direction, [x], [y]

Arguments

Parameter Description
Direction Required. A String value.

The direction in which to swipe the device.

Possible values:
- up
- down
- left
- right

x Optional. An integer value.

The x-coordinate at which to start the swipe. Note that the specified coordinates are relative to the upper left corner of the device. The default value is the center of the device.


Default value = -9999
y Optional. An integer value.

The y-coordinate at which to start the swipe. Note that the specified coordinates are relative to the upper left corner of the device. The default value is the center of the device.


Default value = -9999

Return Type

None

IMPORTANT

During recording sessions on Android devices, this method is not recorded. You can add it to the test manually.


 

Back to top

Touch Method

Description

Touches the device at the specified coordinates. (Android Only)

Syntax

object.Touch x, y

Arguments

Parameter Description
x Required. An integer value.

The x-coordinate of the touch. Note that the specified coordinates are relative to the upper left corner of the device.

y Required. An integer value.

The y-coordinate of the touch. Note that the specified coordinates are relative to the upper left corner of the device.

Return Type

None

IMPORTANT

To record Touch steps on a device, switch the Mobile Center to Analog recording mode. This is supported for Android devices only. To switch the recording mode, use the control on the left side of the remote access window displaying the device's interface.

Example


Back to top

UploadMedia Method

Description

Uploads a file for sensor simulation to the Mobile Center server.

Syntax

object.UploadMedia ReferenceName, FilePath, [SaveToPic, Overwrite]

Arguments

Parameter Description
ReferenceName

Required. A string.

The identical name of the file.

When recording this method, the parameter is automatically generated by Mobile Center.

FilePath

Required. A string value.

The path to one image or video file. This value can be a URL or the file system path of the file.

SaveToPic

Optional. A boolean value.

Instructs Mobile Center to save the image to the device's default picture folder.

Overwrite

Optional. A boolean value.

Instructs UFT to send the file to Mobile Center.

Return Type

None


Back to top

See also: