WaitActivity Method

Applies to TestComplete 14.72, last modified on December 24, 2020

Description

Use this method to pause the script execution until the specified activity becomes active on the Android device.

Declaration

AndroidProcessObj.WaitActivity(ActivityNameWaitTimeout)

AndroidProcessObj An expression, variable or parameter that specifies a reference to an AndroidProcess object
ActivityName [in]    Required    String    
WaitTimeout [in]    Optional    Integer Default value: -1   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ActivityName

The name of the activity to wait for.

WaitTimeout

The number of milliseconds to wait until the specified activity becomes active on the device. If Timeout is 0, the method returns immediately. If Timeout is -1, the waiting time is infinite.

Result Value

If the specified activity has been found, the method returns True; otherwise, it returns False.

Example

The following code snippet checks if the specified activity is currently active on the device.

JavaScript, JScript

function test()
{
  if (Mobile.Device("VirtualBox").Process("com.example.orders").WaitActivity("MainActivity", 100))
    Log.Message("MainActivity is found")
  else
    Log.Message("MainActivity is not found");
}

Python

def test():
  if (Mobile.Device("VirtualBox").Process("com.example.orders").WaitActivity("MainActivity", 100)):
    Log.Message("MainActivity is found")
  else:
    Log.Message("MainActivity is not found")

VBScript

Sub test
  If Mobile.Device("VirtualBox").Process("com.example.orders").WaitActivity("MainActivity", 100) Then
    Log.Message "MainActivity is found"
  Else
    Log.Message "MainActivity is not found"
  End If
End Sub

DelphiScript

procedure test();
begin
  if (Mobile.Device('VirtualBox').Process('com.example.orders').WaitActivity('MainActivity', 100)) then
    Log.Message('MainActivity is found')
  else
    Log.Message('MainActivity is not found');
end;

C++Script, C#Script

function test()
{
  if (Mobile["Device"]("VirtualBox")["Process"]("com.example.orders")["WaitActivity"]("MainActivity", 100))
    Log["Message"]("MainActivity is found")
  else
    Log["Message"]("MainActivity is not found");
}

See Also

AndroidProcess Object
CurrentActivity Property
Waiting for Activities in Android Open Applications
Testing Android Applications

Highlight search results