WaitForState Method

Applies to TestComplete 15.63, last modified on April 23, 2024
The Network Suite functionality is deprecated. We don’t recommend using it for distributed testing. Consider using a CI/CD system for managing distributed tests. See Migrating Distributed Tests to CI/CD Systems for details. In case you need to run web tests on multiple environments in parallel, you can also try using your project’s Execution Plan.

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(State, WaitTime)

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