Utils.CreateStubObject Method

Applies to TestComplete 15.44, last modified on November 10, 2022

Description

The Utils.CreateStubObject method creates a stub object. This object has only one property, Exists, which equals False.

TestComplete object search methods (FindChild, WaitWindow and others) return a stub object if nothing was found. If you implement your own search function, you will be able to return the Utils.CreateStubObject value if nothing is found, so that your search function works similar to TestComplete search methods.

Declaration

Utils.CreateStubObject()

Result A stub object.

Applies To

The method is applied to the following object:

Result Value

A stub object with the Exists property set to False.

Remarks

The aqObject.IsSupported and BuiltIn.IsSupported methods always return True for stub objects, regardless of the specified member name. However, in tests, you can use only the Exists property of stub objects. Accessing other properties and methods will raise the “Object doesn’t support this property or method” exception.

Example

The example below creates a stub object and logs its Exists property value:

JavaScript, JScript

function Test()
{
  var objStub = Utils.CreateStubObject();
  Log.Message(objStub.Exists); // False
}

Python

def Test():
  objStub = Utils.CreateStubObject()
  Log.Message(str(objStub.Exists)) # False

VBScript

Sub Test
  Dim objStub
  Set objStub = Utils.CreateStubObject
  Log.Message objStub.Exists ' False
End Sub

DelphiScript

procedure Test;
var objStub;
begin
  objStub := Utils.CreateStubObject;
  Log.Message(objStub.Exists); // False
end;

C++Script, C#Script

function Test()
{
  var objStub = Utils["CreateStubObject"]();
  Log["Message"](objStub["Exists"]); // False
}

See Also

EmptyObject Property
EmptyVariant Property

Highlight search results