Object Model Reference for GUI Testing > Mobile > CallRestAPI Method

MobileUtil Object

This topic describes the MobileUtil test object, which enables you to set or modify Mobile related settings for your test.

Using the MobileUtil test object

Web browsers on mobile devices

If you are testing a Web browser running on a Mobile device, use the LaunchBrowser or LaunchMobileBrowserWithID.

Testing both Mobile and Web objects

If you use these methods in a test with Mobile objects and Web objects, the test uses the original Record and Run settings or settings specified in the test's application area.

MobileUtil method placement

Use the SetActiveMobileDevice and SetActiveMobileDeviceByID methods to set a device only before any additional web steps.

Note: Using these methods after already having set a device may produce unexpected results.

For example, use this method as follows:

MobileUtil.SetActiveMobileDevice(DeviceB)

Device().App().MobileButton().Click

Device().App().MobileButton().Click

Workaround: To switch devices in the middle of your test, use the Device Object methods. For example:

Device1.App().MobileButton().tab

Device2.App().MobileButton().tab

Enables you to set or modify Mobile related settings for your test.

Back to top

Method reference

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

Enables you to set or modify Mobile related settings for your test.

CallRestAPI Sends a REST API call to Mobile Center with a specified URL and body content.
SetActiveMobileDevice Sets the active mobile device to use for the test.
SetActiveMobileDeviceByID Sets the active mobile device to use for the test by using the device ID.

Back to top

CallRestAPI

Description

Sends a REST API call to Mobile Center with a specified URL and body content.

Syntax

object.CallAPI (method, url, body)

Arguments

Parameter Description
method

String. The HTTP method, and one of the following:

  • REST_DELETE
  • REST_GET
  • REST_POST
  • REST_PUT
url

String. The API URL, in the form of a relative path.

This URL should not include the Mobile Center server URL.

For example: rest/v2/public/reservation

body

Optional. String, in quotes.

The REST call body content.

Return Type

String, the response returned from the Mobile Center server.

Example

The following example creates a new administrator user.

Response = MobileUtil.CallRestAPI (Rest_Post, "rest/v2/users" , "{""name"": ""administrator@default.com"", ""password"": ""Password1"", ""roles"": [ ""admin"" ]}")

Back to top

SetActiveMobileDevice

Description

Sets the active mobile device to use for the test.

Syntax

object.SetActiveMobileDevice device_ostype, device_osversion, device_model, device_manufacturer

Arguments

Parameter Description
device_ostype

Required. A string.

The operating system on the mobile device.

Possible values:

  • iOS
  • Android
device_osversion

Optional. A string.

The operating system running on the mobile device.

device_model

Optional A string.

The model of the device

device_manufacturer

Optional. A string.

The manufacturer of the mobile device.

Return Type

None

Back to top

SetActiveMobileDeviceByID

Description

Sets the active mobile device to use for the test by using the device ID.

Syntax

object.SetActiveMobileDeviceByID device_id

Arguments

Parameter Description
device_id

Required. A string.

The id property assigned to the device by Mobile Center.

Return Type

None

Back to top

See also: