Utils.CreateStubObject Method

Applies to TestComplete 15.64, last modified on May 16, 2024


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.



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.


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.


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


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


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


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

C++Script, C#Script

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

See Also

EmptyObject Property
EmptyVariant Property

Highlight search results