Connected Property

Applies to TestComplete 15.69, last modified on November 13, 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.

Description

Specifies whether the given mobile device is connected.

Declaration

ProgObj.Connected

Read-Only Property Boolean
ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section

Applies To

The property is applied to the following objects:

Property Value

True if the device is connected, False otherwise.

Example

The following example checks whether a mobile device is connected to the computer and posts information about the device to the test log.

JavaScript, JScript

function Test()
{
  // Specify the current device
  Mobile.SetCurrent("MyDevice");

  // Check whether the device is connected
  if (Mobile.Device().Connected)
  {
    // Post information about the device to the log
    Log.Message(Mobile.Device().DeviceID);
    Log.Message(Mobile.Device().DeviceName);
  }
  else
    Log.Message("The device is disconnected.")
}

Python

def Test():
  # Specify the current device
  Mobile.SetCurrent("MyDevice")

  # Check whether the device is connected
  if Mobile.Device().Connected:
    # Post information about the device to the log
    Log.Message(Mobile.Device().DeviceID)
    Log.Message(Mobile.Device().DeviceName)
  else:
    Log.Message("The device is disconnected.")

VBScript

Sub Test
  ' Specify the current device
  Call Mobile.SetCurrent("MyDevice")

  ' Check whether the device is connected
  If Mobile.Device.Connected Then

    ' Post information about the device to the log
    Call Log.Message(Mobile.Device.DeviceID)
    Call Log.Message(Mobile.Device.DeviceName)

  Else
    Call Log.Message("The device is disconnected.")
  End If
End Sub

DelphiScript

procedure Test;
var PackObj: OleVariant;
begin
  // Specify the current device
  Mobile.SetCurrent('MyDevice');

  // Check whether the device is connected
  if Mobile.Device.Connected then
  begin
    // Post information about the device to the log
    Log.Message(Mobile.Device.DeviceID);
    Log.Message(Mobile.Device.DeviceName);
  end
  else
    Log.Message('The device is disconnected.')
end;

C++Script, C#Script

function Test()
{
  // Specify the current device
  Mobile["SetCurrent"]("MyDevice");

  // Check whether the device is connected
  if (Mobile["Device"]["Connected"])
  {
    // Post information about the device to the log
    Log["Message"](Mobile["Device"]["DeviceID"]);
    Log["Message"](Mobile["Device"]["DeviceName"]);
  }
  else
    Log["Message"]("The device is disconnected.")
}

See Also

Testing Android Applications (Legacy)
Testing iOS Applications (Legacy)
AndroidDevice Object
iOSDevice Object

Highlight search results