Sensor Property

Applies to TestComplete 15.65, last modified on July 17, 2024
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.


Provides access to a particular built-in sensor of the mobile device and to its measurements.

To determine the total number of built-in sensors that are available on the device, see the SensorsCount property.



Read-Only Property An iOSSensor object
iOSDeviceObj An expression, variable or parameter that specifies a reference to an iOSDevice object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:


The property has the following parameter:


The index of the desired built-in sensor. The index ranges from 0 to SensorsCount - 1.

Use one of the following values to get the sensor you want:

Index Sensor name
0 Accelerometer
1 Gyroscope
2 Magnetometer
3 Attitude

Property Value

The iOSSensor object that provides information about the specified sensor and its measurements.


If the connected mobile device does not have a sensor with the specified index, an error occurs.


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++)


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

  for i in range (0, Mobile.Device().SensorsCount - 1):


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)
End Sub


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

  for i := 0 to Mobile.Device.SensorsCount - 1 do 

C++Script, C#Script

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

  for (var i = 0; i < Mobile["Device"]["SensorsCount"]; i++)

See Also

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

Highlight search results