iOSSensor Object

Applies to TestComplete 15.63, last modified on April 10, 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.


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


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



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)
iOSDevice Object
Sensor Property

Highlight search results