WaitForState Method

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

The WaitForState method delays script execution until the job reaches the specified state, unless the specified time limit is reached first.

Declaration

JobObj.WaitForState(StateWaitTime)

JobObj An expression, variable or parameter that specifies a reference to a Job object
State [in]    Required    Integer    
WaitTime [in]    Optional    Integer Default value: 0   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

State

Specifies the job’s state to wait for. Read the Network Suite States topic to learn about available job states.

WaitTime

Sets the time limit in milliseconds. 0 means an infinite time limit.

Result Value

True if the expected state is reached, and False otherwise.

Remarks

Use the Job.State property to simply check the job’s state.

Example

The following script halts job execution if it does not stop at the specified time.

JavaScript, JScript

function Test()
{
  var Job = NetworkSuite.Jobs.ItemByName("Job1");
  ...
  if (! Job.WaitForState(ns_Idle, 600000))
    Job.Stop();
}

Python

def Test():
  Job = NetworkSuite.Jobs.ItemByName["Job1"]
  # ...
  if not Job.WaitForState(ns_Idle, 600000):
    Job.Stop()

VBScript

Sub Test
  Set Job = NetworkSuite.Jobs.ItemByName("Job1")
  ...
  If Not Job.WaitForState(ns_Idle, 600000) Then
    Job.Stop
  End If
End Sub

DelphiScript

procedure Test;
var Job;
begin
  Job := NetworkSuite.Jobs.ItemByName['Job1'];
  ...
  if not Job.WaitForState(ns_Idle, 600000) then
    Job.Stop;
end;

C++Script, C#Script

function Test()
{
  var Job = NetworkSuite["Jobs"]["ItemByName"]("Job1");
  ...
  if (! Job["WaitForState"](ns_Idle, 600000))
    Job["Stop"]();
}

See Also

Distributed Testing
Stop Method
Run Method
State Property
OnNetJobStateChange Event

Highlight search results