iOSSensor Object

Applies to TestComplete 15.47, last modified on January 20, 2023
The information below concerns legacy mobile tests that work with mobile devices connected to the local computer. For new mobile tests, we recommend using the newer cloud-compatible approach.

Description

The iOSSensor object represents a sensor installed on an iOS device. You can access the following sensors from your automated tests (provided that the device has them):

Index Sensor name
0 Accelerometer
1 Gyroscope
2 Magnetometer
3 Attitude

To access a specific sensor, use the device’s Sensor(Index) property. You can then get the sensor's Name property and measured values. For more information, see Getting Data From Mobile Device Sensors (Legacy).

Requirements

An instrumented (prepared) iOS application must be running on the device.

Members

Example

The script below lists the names of all the sensors available on the connected iOS device:

JavaScript, JScript

function ListSensors()
{
  Mobile.SetCurrent("iPad John Smith");

  for (var i = 0; i < Mobile.Device().SensorsCount; i++)
  {
    Log.Message(Mobile.Device().Sensor(i).Name);
  }
}

Python

def ListSensors():
  Mobile.SetCurrent("iPad John Smith")

  for i in range (0, Mobile.Device().SensorsCount - 1):
    Log.Message(Mobile.Device().Sensor(i).Name)

VBScript

Sub ListSensors
  Dim i
  Call Mobile.SetCurrent("iPad John Smith")
  
  For i = 0 To Mobile.Device.SensorsCount - 1
    Call Log.Message(Mobile.Device.Sensor(i).Name)
  Next
End Sub

DelphiScript

procedure ListSensors;
var i;
begin
  Mobile.SetCurrent('iPad John Smith');

  for i := 0 to Mobile.Device.SensorsCount - 1 do 
  begin
    Log.Message(Mobile.Device.Sensor(i).Name);
  end;
end;

C++Script, C#Script

function ListSensors()
{
  Mobile["SetCurrent"]("iPad John Smith");

  for (var i = 0; i < Mobile["Device"]["SensorsCount"]; i++)
  {
    Log["Message"](Mobile["Device"]["Sensor"](i)["Name"]);
  }
}

See Also

Getting Data From Mobile Device Sensors (Legacy)
iOSDevice Object
Sensor Property

Highlight search results