Waiting for Object State in iOS Applications (Legacy)

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.

When testing mobile applications, you may need to delay the test execution until an application object is in a specific state. For example, your test may need to wait until a control in the application is enabled before simulating user actions against it.

TestComplete adds a number of custom properties and methods to objects that can help you determine an object’s state.

To delay your test execution until an object has a specific property value, use the WaitProperty method. TestComplete adds this method to all the tested objects. The method delays the test execution until the specified property of the object (it can be either a native property or a property added by TestComplete) takes the specified value or until the timeout elapses.

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Run the tested application
  Mobile.Device().ApplicationManager.RunApplication(SampleApp)
 
  // Obtain the Button object
  var btn = Mobile.Device().Process("SampleApp").Window(0).Button("Simple Button");
  if (btn.WaitProperty("Enabled", true, 10000))
  {
    // The button is enabled
    // ...
  }
  else
  {
    // The button is disabled
    // ...
  }
  
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone");
  # Run the tested application
  Mobile.Device().ApplicationManager.RunApplication(SampleApp);
 
  # Obtain the Button object
  btn = Mobile.Device().Process("SampleApp").Window(0).Button("Simple Button");
  if (btn.WaitProperty("Enabled", True, 10000)):
    # The button is enabled
    # ...
  else:
    # The button is disabled
    # ...

VBScript

Sub Test()
  Dim btn
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  
  ' Run the tested application
  Mobile.Device.ApplicationManager.RunApplication(SampleApp)
 
  ' Obtain the Button object
  Set btn = Mobile.Device.Process("SampleApp").Window(0).Button("Simple Button")
  If btn.WaitProperty("Enabled", true, 10000) Then
    ' The button is enabled
    ' ...
  Else
    ' The button is disabled
    ' ...
  End If

  
End Sub

DelphiScript

procedure Test();
var
  btn;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Run the tested application
  Mobile.Device.ApplicationManager.RunApplication(SampleApp);
 
  // Obtain the Button object
  btn := Mobile.Device.Process('SampleApp').Window.Button('Simple Button');
  if btn.WaitProperty('Enabled', true, 10000) then
    begin
      // The button is enabled
      // ...
    end
  else
    begin
      // The button is disabled
      // ...
    end;
  
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Run the tested application
  Mobile["Device"]["ApplicationManager"].RunApplication(SampleApp)
 
  // Obtain the Button object
  var btn = Mobile["Device"].Process("SampleApp")["Window"](0)["Button"]("Simple Button");
  if (btn["WaitProperty"]("Enabled", true, 10000))
  {
    // The button is enabled
    // ...
  }
  else
  {
    // The button is disabled
    // ...
  }
  
}

See Also

Waiting for Objects in iOS Applications (Legacy)
Testing iOS Applications (Legacy)
Testing iOS Applications - Overview (Legacy)

Highlight search results